Realtime transcriptie toevoegen aan uw toepassing

Warning

Azure Communication Services voert ingrijpende wijzigingen door en sommige services worden uitgefaseerd. Lees meer in de gids voor pensioen- en veranderingen.

Deze handleiding helpt u beter inzicht te krijgen in de verschillende manieren waarop u Azure Communication Services-aanbiedingen van realtimetranscriptie kunt gebruiken via Call Automation SDK's.

Vereisten

Een WebSocket-server instellen

Voor Azure Communication Services moet uw servertoepassing een WebSocket-server instellen om transcriptie in realtime te streamen. WebSocket is een gestandaardiseerd protocol dat een full-duplex communicatiekanaal biedt via één TCP-verbinding. U kunt eventueel Azure-services Azure WebApps gebruiken waarmee u een toepassing kunt maken voor het ontvangen van transcripties via een websocket-verbinding. Volg deze snelle startgids.

Een oproep plaatsen

In deze quickstart gaan we ervan uit dat u al bekend bent met het starten van oproepen. Als u meer wilt weten over het starten en tot stand brengen van gesprekken, kunt u onze quickstart volgen. Voor deze quickstart doorlopen we het proces van het starten van transcriptie voor zowel binnenkomende oproepen als uitgaande oproepen.

Wanneer u met realtime transcriptie werkt, hebt u een aantal opties voor wanneer en hoe u transcriptie start:

Optie 1: begint bij het beantwoorden of starten van een oproep

Optie 2: transcriptie starten tijdens een doorlopend gesprek

Optie 3: transcriptie starten bij het maken van verbinding met een Azure Communication Services Rooms-aanroep

In deze handleiding demonstreren we optie 2 en 3 door de transcriptie te starten tijdens een doorlopend gesprek of wanneer we verbinding maken met een Rooms-gesprek. Standaard is de 'startTranscription' ingesteld op false op het moment van beantwoorden of maken van een aanroep.

Een oproep maken en de transcriptiegegevens opgeven

Definieer de TranscriptionOptions voor ACS om op te geven wanneer de transcriptie moet worden gestart, geef de landinstelling op voor transcriptie en de websocketverbinding voor het verzenden van het transcript.

var createCallOptions = new CreateCallOptions(callInvite, callbackUri)
{
    CallIntelligenceOptions = new CallIntelligenceOptions() { CognitiveServicesEndpoint = new Uri(cognitiveServiceEndpoint) },
    TranscriptionOptions = new TranscriptionOptions(new Uri(""), "en-US", false, TranscriptionTransport.Websocket)
};
CreateCallResult createCallResult = await callAutomationClient.CreateCallAsync(createCallOptions);

Sentimentanalyse (Preview)

Houd de emotionele toon van gesprekken in realtime bij om interacties tussen klanten en agenten te ondersteunen en stelt supervisors in staat om zo nodig tussen te komen. Beschikbaar in openbare preview via createCall, answerCall en startTranscription.

Een aanroep maken waarvoor Sentimentanalyse is ingeschakeld

// Define transcription options with sentiment analysis enabled
var transcriptionOptions = new TranscriptionOptions
{
    IsSentimentAnalysisEnabled = true
};

var callIntelligenceOptions = new CallIntelligenceOptions
{
    CognitiveServicesEndpoint = new Uri(cognitiveServiceEndpoint)
};

var createCallOptions = new CreateCallOptions(callInvite, new Uri("https://test"))
{
    CallIntelligenceOptions = callIntelligenceOptions,
    TranscriptionOptions = transcriptionOptions
};

CreateCallResult createCallResult = await callAutomationClient.CreateCallAsync(createCallOptions);

Een gesprek beantwoorden waarvoor Sentimentanalyse is ingeschakeld

// Define transcription options with sentiment analysis enabled
var transcriptionOptions = new TranscriptionOptions
{
    IsSentimentAnalysisEnabled = true
};

var answerCallOptions = new AnswerCallOptions(incomingCallContext, callbackUri)
{
    TranscriptionOptions = transcriptionOptions
};

var answerCallResult = await client.AnswerCallAsync(answerCallOptions);

PII-anonimisering (preview)

Automatisch gevoelige informatie identificeren en maskeren, zoals namen, adressen of identificatienummers, om de naleving van privacy en regelgeving te waarborgen. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek beantwoorden met PII Redaction ingeschakeld

var transcriptionOptions = new TranscriptionOptions 
{ 
   PiiRedactionOptions = new PiiRedactionOptions 
   { 
       IsEnabled = true, 
       RedactionType = RedactionType.MaskWithCharacter 
   },  
}; 
 
var options = new AnswerCallOptions(incomingCallContext, callbackUri) 
{ 
   TranscriptionOptions = transcriptionOptions, 
}; 
 
//Answer call request 
var answerCallResult = await client.AnswerCallAsync(options); 

Opmerking

Als piI-redaction is ingeschakeld, ontvangt u alleen de bewerkte tekst.

Realtime taaldetectie (Preview)

Automatisch gesproken talen detecteren om natuurlijke, menselijke communicatie mogelijk te maken en handmatige taalselectie te elimineren. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek maken waarbij realtime taaldetectie is ingeschakeld

var transcriptionOptions = new TranscriptionOptions 
{ 
   Locales = new List<string> { "en-US", "fr-FR", "hi-IN" }
};

var createCallOptions = new CreateCallOptions(callInviteOption, new Uri("https://test")) 
{ 
    TranscriptionOptions = transcriptionOptions 
}; 
 
//CreateCall request 
var createCallRequest = await client.CreateCallAsync(createCallOptions);

Opmerking

Als u de taalidentificatie wilt stoppen nadat deze is gestart, gebruikt u de updateTranscription API en stelt u expliciet de taal in die u wilt gebruiken voor het transcript. Hierdoor wordt automatische taaldetectie uitgeschakeld en wordt transcriptie naar de opgegeven taal vergrendeld.

Verbinding maken met een Rooms-gesprek en transcriptiedetails opgeven

Als u verbinding maakt met een ACS-ruimte en transcriptie wilt gebruiken, configureert u de transcriptieopties als volgt:

var transcriptionOptions = new TranscriptionOptions(
    transportUri: new Uri(""),
    locale: "en-US", 
    startTranscription: false,
    transcriptionTransport: TranscriptionTransport.Websocket,
    //Only add the SpeechRecognitionModelEndpointId if you have a custom speech model you would like to use
    SpeechRecognitionModelEndpointId = "YourCustomSpeechRecognitionModelEndpointId"
);

var connectCallOptions = new ConnectCallOptions(new RoomCallLocator("roomId"), callbackUri)
{
    CallIntelligenceOptions = new CallIntelligenceOptions() 
    { 
        CognitiveServicesEndpoint = new Uri(cognitiveServiceEndpoint) 
    },
    TranscriptionOptions = transcriptionOptions
};

var connectResult = await client.ConnectCallAsync(connectCallOptions);

Transcriptie starten

Zodra u klaar bent om de transcriptie te starten, kunt u een expliciete aanroep naar Gespreksautomatisering maken om te beginnen met het transcriberen van de oproep.

// Start transcription with options
var transcriptionOptions = new StartTranscriptionOptions
{
    OperationContext = "startMediaStreamingContext",
    IsSentimentAnalysisEnabled = true,

    // Only add the SpeechRecognitionModelEndpointId if you have a custom speech model you would like to use
    SpeechRecognitionModelEndpointId = "YourCustomSpeechRecognitionModelEndpointId"
};

// Start transcription
await callMedia.StartTranscriptionAsync(transcriptionOptions);

// Alternative: Start transcription without options
// await callMedia.StartTranscriptionAsync();

Samenvattingen tijdens een gesprek ophalen (preview)

Verbeter uw gesprekswerkstromen met realtime samenvatting. Door samenvatting in te schakelen in uw transcriptieopties, kan ACS automatisch beknopte samenvattingen van middenoproepen genereren, inclusief beslissingen, actie-items en belangrijke discussiepunten, zonder te wachten tot de oproep is beëindigd. Dit helpt teams op elkaar afgestemd te blijven en snellere follow-ups mogelijk te maken tijdens livegesprekken.

// Define transcription options with call summarization enabled
var transcriptionOptions = new TranscriptionOptions
{
    SummarizationOptions = new SummarizationOptions
    {
        Locale = "en-US"
    }
};

// Answer call with transcription options
var answerCallOptions = new AnswerCallOptions(incomingCallContext, callbackUri)
{
    TranscriptionOptions = transcriptionOptions
};

var answerCallResult = await client.AnswerCallAsync(answerCallOptions);

Extra headers:

De correlatie-id en de oproepverbindings-id zijn nu opgenomen in de WebSocket-headers voor verbeterde traceerbaarheid x-ms-call-correlation-id en x-ms-call-connection-id.

Transcriptiestroom ontvangen

Wanneer de transcriptie start, ontvangt uw websocket de payload van de transcriptiemetagegevens als het eerste pakket.

{
    "kind": "TranscriptionMetadata",
    "transcriptionMetadata": {
        "subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
        "locale": "en-us",
        "callConnectionId": "65c57654=f12c-4975-92a4-21668e61dd98",
        "correlationId": "65c57654=f12c-4975-92a4-21668e61dd98"
    }
}

Transcriptiegegevens ontvangen

Na de metagegevens zijn de volgende pakketten die uw websocket ontvangt TranscriptionData voor de getranscribeerde audio.

{
    "kind": "TranscriptionData",
    "transcriptionData": {
        "text": "Testing transcription.",
        "format": "display",
        "confidence": 0.695223331451416,
        "offset": 2516998782481234400,
        "words": [
            {
                "text": "testing",
                "offset": 2516998782481234400
            },
            {
                "text": "testing",
                "offset": 2516998782481234400
            }
        ],
        "participantRawID": "8:acs:",
        "resultStatus": "Final"
    }
}

Transcriptiestroom ontvangen met ingeschakelde AI-mogelijkheden (preview)

Wanneer transcriptie is ingeschakeld tijdens een aanroep, verzendt Azure Communication Services metagegevens die de configuratie en context van de transcriptiesessie beschrijven. Dit omvat details zoals de landinstelling, oproepverbindings-id, instellingen voor sentimentanalyse en voorkeuren voor piI-redaction. Ontwikkelaars kunnen deze nettolading gebruiken om de transcriptie-instellingen te controleren, configuraties te controleren of problemen op te lossen met betrekking tot realtime transcriptiefuncties die zijn verbeterd door AI.

{
  "kind": "TranscriptionMetadata",
  "transcriptionMetadata": {
    "subscriptionId": "863b5e55-de0d-4fc3-8e58-2d68e976b5ad",
    "locale": "en-US",
    "callConnectionId": "02009180-9dc2-429b-a3eb-d544b7b6a0e1",
    "correlationId": "62c8215b-5276-4d3c-bb6d-06a1b114651b",
    "speechModelEndpointId": null,
    "locales": [],
    "enableSentimentAnalysis": true,
    "piiRedactionOptions": {
      "enable": true,
      "redactionType": "MaskWithCharacter"
    }
  }
}

Transcriptiegegevens ontvangen met ingeschakelde AI-mogelijkheden (Preview)

Na het eerste metadatapakket gaat uw WebSocket-verbinding TranscriptionData-gebeurtenissen ontvangen voor elk segment van de getranscribeerde audio. Deze pakketten omvatten de getranscribeerde tekst, betrouwbaarheidsscore, timinginformatie en, indien ingeschakeld, sentimentanalyse en PII-redaction. Deze gegevens kunnen worden gebruikt voor het bouwen van realtime dashboards, het activeren van werkstromen of het analyseren van gespreksdynamiek tijdens het gesprek.

{
  "kind": "TranscriptionData",
  "transcriptionData": {
    "text": "My date of birth is *********.",
    "format": "display",
    "confidence": 0.8726407289505005,
    "offset": 309058340,
    "duration": 31600000,
    "words": [],
    "participantRawID": "4:+917020276722",
    "resultStatus": "Final",
    "sentimentAnalysisResult": {
      "sentiment": "neutral"
    }
  }
}

Transcriptiestroom verwerken in de websocket-server

using WebServerApi;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();
app.UseWebSockets();
app.Map("/ws", async context =>
{
    if (context.WebSockets.IsWebSocketRequest)
    {
        using var webSocket = await context.WebSockets.AcceptWebSocketAsync();
        await HandleWebSocket.Echo(webSocket);
    }
    else
    {
        context.Response.StatusCode = StatusCodes.Status400BadRequest;
    }
});

app.Run();

Updates voor uw code voor de websocket-handler

using Azure.Communication.CallAutomation;
using System.Net.WebSockets;
using System.Text;

namespace WebServerApi
{
    public class HandleWebSocket
    {
        public static async Task Echo(WebSocket webSocket)
        {
            var buffer = new byte[1024 * 4];
            var receiveResult = await webSocket.ReceiveAsync(
                new ArraySegment(buffer), CancellationToken.None);

            while (!receiveResult.CloseStatus.HasValue)
            {
                string msg = Encoding.UTF8.GetString(buffer, 0, receiveResult.Count);
                var response = StreamingDataParser.Parse(msg);

                if (response != null)
                {
                    if (response is AudioMetadata audioMetadata)
                    {
                        Console.WriteLine("***************************************************************************************");
                        Console.WriteLine("MEDIA SUBSCRIPTION ID-->"+audioMetadata.MediaSubscriptionId);
                        Console.WriteLine("ENCODING-->"+audioMetadata.Encoding);
                        Console.WriteLine("SAMPLE RATE-->"+audioMetadata.SampleRate);
                        Console.WriteLine("CHANNELS-->"+audioMetadata.Channels);
                        Console.WriteLine("LENGTH-->"+audioMetadata.Length);
                        Console.WriteLine("***************************************************************************************");
                    }
                    if (response is AudioData audioData)
                    {
                        Console.WriteLine("***************************************************************************************");
                        Console.WriteLine("DATA-->"+audioData.Data);
                        Console.WriteLine("TIMESTAMP-->"+audioData.Timestamp);
                        Console.WriteLine("IS SILENT-->"+audioData.IsSilent);
                        Console.WriteLine("***************************************************************************************");
                    }

                    if (response is TranscriptionMetadata transcriptionMetadata)
                    {
                        Console.WriteLine("***************************************************************************************");
                        Console.WriteLine("TRANSCRIPTION SUBSCRIPTION ID-->"+transcriptionMetadata.TranscriptionSubscriptionId);
                        Console.WriteLine("LOCALE-->"+transcriptionMetadata.Locale);
                        Console.WriteLine("CALL CONNECTION ID--?"+transcriptionMetadata.CallConnectionId);
                        Console.WriteLine("CORRELATION ID-->"+transcriptionMetadata.CorrelationId);
                        Console.WriteLine("LOCALES-->" + transcriptionMetadata.Locales);  
                        Console.WriteLine("PII REDACTION OPTIONS ISENABLED-->" + transcriptionMetadata.PiiRedactionOptions?.IsEnabled);  
                        Console.WriteLine("PII REDACTION OPTIONS - REDACTION TYPE-->" + transcriptionMetadata.PiiRedactionOptions?.RedactionType); 
                        Console.WriteLine("***************************************************************************************");
                    }
                    if (response is TranscriptionData transcriptionData)
                    {
                        Console.WriteLine("***************************************************************************************");
                        Console.WriteLine("TEXT-->"+transcriptionData.Text);
                        Console.WriteLine("FORMAT-->"+transcriptionData.Format);
                        Console.WriteLine("OFFSET-->"+transcriptionData.Offset);
                        Console.WriteLine("DURATION-->"+transcriptionData.Duration);
                        Console.WriteLine("PARTICIPANT-->"+transcriptionData.Participant.RawId);
                        Console.WriteLine("CONFIDENCE-->"+transcriptionData.Confidence);
                        Console.WriteLine("SENTIMENT ANALYSIS RESULT-->" + transcriptionData.SentimentAnalysisResult?.Sentiment);

                        foreach (var word in transcriptionData.Words)
                        {
                            Console.WriteLine("TEXT-->"+word.Text);
                            Console.WriteLine("OFFSET-->"+word.Offset);
                            Console.WriteLine("DURATION-->"+word.Duration);
                        }
                        Console.WriteLine("***************************************************************************************");
                    }
                }

                await webSocket.SendAsync(
                    new ArraySegment(buffer, 0, receiveResult.Count),
                    receiveResult.MessageType,
                    receiveResult.EndOfMessage,
                    CancellationToken.None);

                receiveResult = await webSocket.ReceiveAsync(
                    new ArraySegment(buffer), CancellationToken.None);
            }

            await webSocket.CloseAsync(
                receiveResult.CloseStatus.Value,
                receiveResult.CloseStatusDescription,
                CancellationToken.None);
        }
    }
}

Transcriptie bijwerken

In situaties waarin gebruikers in uw toepassing hun voorkeurstaal kunnen selecteren, kunt u ook de transcriptie in die taal vastleggen. Hiervoor kunt u de taalinstelling voor transcriptie bijwerken met de Call Automation SDK.

UpdateTranscriptionOptions updateTranscriptionOptions = new UpdateTranscriptionOptions(locale)
{
OperationContext = "UpdateTranscriptionContext",
//Only add the SpeechRecognitionModelEndpointId if you have a custom speech model you would like to use
SpeechRecognitionModelEndpointId = "YourCustomSpeechRecognitionModelEndpointId"
};

await client.GetCallConnection(callConnectionId).GetCallMedia().UpdateTranscriptionAsync(updateTranscriptionOptions);

Transcriptie stoppen

Wanneer uw toepassing moet stoppen met luisteren naar de transcriptie, kunt u de StopTranscription-aanvraag gebruiken om Call Automation te laten weten dat ze geen transcriptiegegevens meer naar uw websocket verzenden.

StopTranscriptionOptions stopOptions = new StopTranscriptionOptions()
{
    OperationContext = "stopTranscription"
};

await callMedia.StopTranscriptionAsync(stopOptions);

Een oproep maken en de transcriptiegegevens opgeven

Definieer de TranscriptionOptions voor ACS om op te geven wanneer de transcriptie moet worden gestart, de landinstelling voor transcriptie en de websocketverbinding voor het verzenden van het transcript.

CallInvite callInvite = new CallInvite(target, caller); 

CallIntelligenceOptions callIntelligenceOptions = new CallIntelligenceOptions()
    .setCognitiveServicesEndpoint(appConfig.getCognitiveServiceEndpoint()); 

TranscriptionOptions transcriptionOptions = new TranscriptionOptions(
    appConfig.getWebSocketUrl(), 
    TranscriptionTransport.WEBSOCKET, 
    "en-US", 
    false,
    "your-endpoint-id-here" // speechRecognitionEndpointId
); 

CreateCallOptions createCallOptions = new CreateCallOptions(callInvite, appConfig.getCallBackUri());
createCallOptions.setCallIntelligenceOptions(callIntelligenceOptions); 
createCallOptions.setTranscriptionOptions(transcriptionOptions); 

Response result = client.createCallWithResponse(createCallOptions, Context.NONE); 
return result.getValue().getCallConnectionProperties().getCallConnectionId(); 

Sentimentanalyse (Preview)

Houd de emotionele toon van gesprekken in realtime bij om interacties tussen klanten en agenten te ondersteunen en stelt supervisors in staat om zo nodig tussen te komen. Beschikbaar in openbare preview via createCall, answerCall en startTranscription.

Een aanroep maken waarvoor Sentimentanalyse is ingeschakeld

CallInvite callInvite = new CallInvite(target, caller);

CallIntelligenceOptions callIntelligenceOptions = new CallIntelligenceOptions()
    .setCognitiveServicesEndpoint(cognitiveServicesEndpoint);

TranscriptionOptions transcriptionOptions = new TranscriptionOptions("en-ES")
    .setTransportUrl(websocketUriHost)
    .setEnableSentimentAnalysis(true) // Enable sentiment analysis
    .setLocales(locales);

CreateCallOptions createCallOptions = new CreateCallOptions(callInvite, callbackUri.toString())
    .setCallIntelligenceOptions(callIntelligenceOptions)
    .setTranscriptionOptions(transcriptionOptions);

// Create call request
Response<CreateCallResult> result = client.createCallWithResponse(createCallOptions, Context.NONE);

Een gesprek beantwoorden waarvoor Sentimentanalyse is ingeschakeld

TranscriptionOptions transcriptionOptions = new TranscriptionOptions("en-ES")
    .setTransportUrl(websocketUriHost)
    .setEnableSentimentAnalysis(true) // Enable sentiment analysis
    .setLocales(locales);

AnswerCallOptions answerCallOptions = new AnswerCallOptions(data.getString("incomingCallContext"), callbackUri)
    .setCallIntelligenceOptions(callIntelligenceOptions)
    .setTranscriptionOptions(transcriptionOptions);

// Answer call request
Response<AnswerCallResult> answerCallResponse = client.answerCallWithResponse(answerCallOptions, Context.NONE);

PII-redactie (Preview)

Automatisch gevoelige informatie identificeren en maskeren, zoals namen, adressen of identificatienummers, om de naleving van privacy en regelgeving te waarborgen. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek beantwoorden met PII Redaction ingeschakeld

PiiRedactionOptions piiRedactionOptions = new PiiRedactionOptions()
    .setEnabled(true)
    .setRedactionType(RedactionType.MASK_WITH_CHARACTER);

TranscriptionOptions transcriptionOptions = new TranscriptionOptions("en-ES")
    .setTransportUrl(websocketUriHost)
    .setPiiRedactionOptions(piiRedactionOptions)
    .setLocales(locales);

AnswerCallOptions answerCallOptions = new AnswerCallOptions(data.getString("incomingCallContext"), callbackUri)
    .setCallIntelligenceOptions(callIntelligenceOptions)
    .setTranscriptionOptions(transcriptionOptions);

// Answer call request
Response<AnswerCallResult> answerCallResponse = client.answerCallWithResponse(answerCallOptions, Context.NONE);

Opmerking

Als piI-redaction is ingeschakeld, ontvangt u alleen de bewerkte tekst.

Realtime-taaldetectie (Preview)

Automatisch gesproken talen detecteren om natuurlijke, menselijke communicatie mogelijk te maken en handmatige taalselectie te elimineren. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek maken waarbij realtime taaldetectie is ingeschakeld

var transcriptionOptions = new TranscriptionOptions
{
    Locales = new List<string> { "en-US", "fr-FR", "hi-IN" },
};

var createCallOptions = new CreateCallOptions(callInviteOption, new Uri("https://test"))
{
    TranscriptionOptions = transcriptionOptions
};

var createCallResult = await client.CreateCallAsync(createCallOptions);

Opmerking

Als u de taalidentificatie wilt stoppen nadat deze is gestart, gebruikt u de updateTranscription API en stelt u expliciet de taal in die u wilt gebruiken voor het transcript. Hierdoor wordt automatische taaldetectie uitgeschakeld en wordt transcriptie naar de opgegeven taal vergrendeld.

Verbinding maken met een Rooms-gesprek en transcriptiedetails opgeven

Als u verbinding maakt met een ACS-ruimte en transcriptie wilt gebruiken, configureert u de transcriptieopties als volgt:

TranscriptionOptions transcriptionOptions = new TranscriptionOptions(
    appConfig.getWebSocketUrl(), 
    TranscriptionTransport.WEBSOCKET, 
    "en-US", 
    false,
    "your-endpoint-id-here" // speechRecognitionEndpointId
);

ConnectCallOptions connectCallOptions = new ConnectCallOptions(new RoomCallLocator("roomId"), appConfig.getCallBackUri())
    .setCallIntelligenceOptions(
        new CallIntelligenceOptions()
            .setCognitiveServicesEndpoint(appConfig.getCognitiveServiceEndpoint())
    )
    .setTranscriptionOptions(transcriptionOptions);

ConnectCallResult connectCallResult = Objects.requireNonNull(client
    .connectCallWithResponse(connectCallOptions)
    .block())
    .getValue();

Transcriptie starten

Zodra u klaar bent om de transcriptie te starten, kunt u een expliciete aanroep naar Gespreksautomatisering maken om te beginnen met het transcriberen van de oproep.

//Option 1: Start transcription with options
StartTranscriptionOptions transcriptionOptions = new StartTranscriptionOptions()
    .setOperationContext("startMediaStreamingContext"); 

client.getCallConnection(callConnectionId)
    .getCallMedia()
    .startTranscriptionWithResponse(transcriptionOptions, Context.NONE); 

// Alternative: Start transcription without options
// client.getCallConnection(callConnectionId)
//     .getCallMedia()
//     .startTranscription();

Samenvattingen tijdens een gesprek ophalen (preview)

Verbeter uw gesprekswerkstromen met realtime samenvatting. Door samenvatting in te schakelen in uw transcriptieopties, kan ACS automatisch beknopte samenvattingen van middenoproepen genereren, inclusief beslissingen, actie-items en belangrijke discussiepunten, zonder te wachten tot de oproep is beëindigd. Dit helpt teams op elkaar afgestemd te blijven en snellere follow-ups mogelijk te maken tijdens livegesprekken.

SummarizationOptions summarizationOptions = new SummarizationOptions()
    .setEnableEndCallSummary(true)
    .setLocale("en-US");

TranscriptionOptions transcriptionOptions = new TranscriptionOptions("en-ES")
    .setTransportUrl(websocketUriHost)
    .setSummarizationOptions(summarizationOptions)
    .setLocales(locales);

AnswerCallOptions answerCallOptions = new AnswerCallOptions(data.getString("incomingCallContext"), callbackUri)
    .setCallIntelligenceOptions(callIntelligenceOptions)
    .setTranscriptionOptions(transcriptionOptions);

// Answer call request
Response<AnswerCallResult> answerCallResponse = client.answerCallWithResponse(answerCallOptions, Context.NONE);

Extra headers:

De correlatie-id en de oproepverbindings-id zijn nu opgenomen in de WebSocket-headers voor verbeterde traceerbaarheid x-ms-call-correlation-id en x-ms-call-connection-id.

Transcriptiestroom ontvangen

Wanneer de transcriptie start, ontvangt uw websocket de payload van de transcriptiemetagegevens als het eerste pakket.

{
    "kind": "TranscriptionMetadata",
    "transcriptionMetadata": {
        "subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
        "locale": "en-us",
        "callConnectionId": "65c57654=f12c-4975-92a4-21668e61dd98",
        "correlationId": "65c57654=f12c-4975-92a4-21668e61dd98"
    }
}

Transcriptiegegevens ontvangen

Na de metagegevens zijn de volgende pakketten die uw websocket ontvangt TranscriptionData voor de getranscribeerde audio.

{
    "kind": "TranscriptionData",
    "transcriptionData": {
        "text": "Testing transcription.",
        "format": "display",
        "confidence": 0.695223331451416,
        "offset": 2516998782481234400,
        "words": [
            {
                "text": "testing",
                "offset": 2516998782481234400
            },
            {
                "text": "testing",
                "offset": 2516998782481234400
            }
        ],
        "participantRawID": "8:acs:",
        "resultStatus": "Final"
    }
}

Transcriptiestroom ontvangen met ingeschakelde AI-mogelijkheden (preview)

Wanneer transcriptie is ingeschakeld tijdens een aanroep, verzendt Azure Communication Services metagegevens die de configuratie en context van de transcriptiesessie beschrijven. Dit omvat details zoals de landinstelling, oproepverbindings-id, instellingen voor sentimentanalyse en voorkeuren voor piI-redaction. Ontwikkelaars kunnen deze nettolading gebruiken om de transcriptie-instellingen te controleren, configuraties te controleren of problemen op te lossen met betrekking tot realtime transcriptiefuncties die zijn verbeterd door AI.

{
  "kind": "TranscriptionMetadata",
  "transcriptionMetadata": {
    "subscriptionId": "863b5e55-de0d-4fc3-8e58-2d68e976b5ad",
    "locale": "en-US",
    "callConnectionId": "02009180-9dc2-429b-a3eb-d544b7b6a0e1",
    "correlationId": "62c8215b-5276-4d3c-bb6d-06a1b114651b",
    "speechModelEndpointId": null,
    "locales": [],
    "enableSentimentAnalysis": true,
    "piiRedactionOptions": {
      "enable": true,
      "redactionType": "MaskWithCharacter"
    }
  }
}

Transcriptiegegevens ontvangen met ingeschakelde AI-mogelijkheden (Preview)

Na het eerste metadatapakket gaat uw WebSocket-verbinding TranscriptionData-gebeurtenissen ontvangen voor elk segment van de getranscribeerde audio. Deze pakketten omvatten de getranscribeerde tekst, betrouwbaarheidsscore, timinginformatie en, indien ingeschakeld, sentimentanalyse en PII-redaction. Deze gegevens kunnen worden gebruikt voor het bouwen van realtime dashboards, het activeren van werkstromen of het analyseren van gespreksdynamiek tijdens het gesprek.

{
  "kind": "TranscriptionData",
  "transcriptionData": {
    "text": "My date of birth is *********.",
    "format": "display",
    "confidence": 0.8726407289505005,
    "offset": 309058340,
    "duration": 31600000,
    "words": [],
    "participantRawID": "4:+917020276722",
    "resultStatus": "Final",
    "sentimentAnalysisResult": {
      "sentiment": "neutral"
    }
  }
}

Transcriptiestroom verwerken in de websocket-server

package com.example;

import org.glassfish.tyrus.server.Server;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class App {
    public static void main(String[] args) {
        Server server = new Server("localhost", 8081, "/ws", null, WebSocketServer.class);

        try {
            server.start();
            System.out.println("Web socket running on port 8081...");
            System.out.println("wss://localhost:8081/ws/server");
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            reader.readLine();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            server.stop();
        }
    }
}

Updates voor uw code voor de websocket-handler

package com.example;

import javax.websocket.OnMessage;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;

import com.azure.communication.callautomation.models.streaming.StreamingData;
import com.azure.communication.callautomation.models.streaming.StreamingDataParser;
import com.azure.communication.callautomation.models.streaming.media.AudioData;
import com.azure.communication.callautomation.models.streaming.media.AudioMetadata;
import com.azure.communication.callautomation.models.streaming.transcription.TranscriptionData;
import com.azure.communication.callautomation.models.streaming.transcription.TranscriptionMetadata;
import com.azure.communication.callautomation.models.streaming.transcription.Word;

@ServerEndpoint("/server")
public class WebSocketServer {
    @OnMessage
    public void onMessage(String message, Session session) {
        StreamingData data = StreamingDataParser.parse(message);

        if (data instanceof AudioMetadata) {
            AudioMetadata audioMetaData = (AudioMetadata) data;
            System.out.println("----------------------------------------------------------------");
            System.out.println("SUBSCRIPTION ID: --> " + audioMetaData.getMediaSubscriptionId());
            System.out.println("ENCODING: --> " + audioMetaData.getEncoding());
            System.out.println("SAMPLE RATE: --> " + audioMetaData.getSampleRate());
            System.out.println("CHANNELS: --> " + audioMetaData.getChannels());
            System.out.println("LENGTH: --> " + audioMetaData.getLength());
            System.out.println("----------------------------------------------------------------");
        }

        if (data instanceof AudioData) {
            AudioData audioData = (AudioData) data;
            System.out.println("----------------------------------------------------------------");
            System.out.println("DATA: --> " + audioData.getData());
            System.out.println("TIMESTAMP: --> " + audioData.getTimestamp());
            System.out.println("IS SILENT: --> " + audioData.isSilent());
            System.out.println("----------------------------------------------------------------");
        }

        if (data instanceof TranscriptionMetadata) {
            TranscriptionMetadata transcriptionMetadata = (TranscriptionMetadata) data;
        
            System.out.println("----------------------------------------------------------------");
            System.out.println("TRANSCRIPTION SUBSCRIPTION ID: --> " + transcriptionMetadata.getTranscriptionSubscriptionId());
            System.out.println("LOCALE: --> " + transcriptionMetadata.getLocale());
            System.out.println("CALL CONNECTION ID: --> " + transcriptionMetadata.getCallConnectionId());
            System.out.println("CORRELATION ID: --> " + transcriptionMetadata.getCorrelationId());
        
            // Check for PII Redaction Options locale
            if (transcriptionMetadata.getPiiRedactionOptions() != null &&
                transcriptionMetadata.getPiiRedactionOptions().getLocale() != null) {
                System.out.println("PII Redaction Locale: --> " + transcriptionMetadata.getPiiRedactionOptions().getLocale());
            }
        
            // Check for detected locales
            if (transcriptionMetadata.getLocales() != null) {
                System.out.println("Detected Locales: --> " + transcriptionMetadata.getLocales());
            }
        
            System.out.println("----------------------------------------------------------------");
        }

        if (data instanceof TranscriptionData) {
            TranscriptionData transcriptionData = (TranscriptionData) data;
            System.out.println("----------------------------------------------------------------");
            System.out.println("TEXT: --> " + transcriptionData.getText());
            System.out.println("FORMAT: --> " + transcriptionData.getFormat());
            System.out.println("CONFIDENCE: --> " + transcriptionData.getConfidence());
            System.out.println("OFFSET: --> " + transcriptionData.getOffset());
            System.out.println("DURATION: --> " + transcriptionData.getDuration());
            System.out.println("RESULT STATUS: --> " + transcriptionData.getResultStatus());
            for (Word word : transcriptionData.getWords()) {
                System.out.println("Text: --> " + word.getText());
                System.out.println("Offset: --> " + word.getOffset());
                System.out.println("Duration: --> " + word.getDuration());
            }
            System.out.println("SENTIMENT:-->" + transcriptionData.getSentimentAnalysisResult().getSentiment()); 
            System.out.println("LANGUAGE IDENTIFIED:-->" + transcriptionData.getLanguageIdentified()); 
            System.out.println("----------------------------------------------------------------");
        }
    }
}

Transcriptie bijwerken

In situaties waarin gebruikers in uw toepassing hun voorkeurstaal kunnen selecteren, kunt u ook de transcriptie in die taal vastleggen. Hiervoor kunt u de taalinstelling voor transcriptie bijwerken met de Call Automation SDK.

UpdateTranscriptionOptions transcriptionOptions = new UpdateTranscriptionOptions()
    .setLocale(newLocale)
    .setOperationContext("transcriptionContext")
    .setSpeechRecognitionEndpointId("your-endpoint-id-here");

client.getCallConnection(callConnectionId)
    .getCallMedia()
    .updateTranscriptionWithResponse(transcriptionOptions, Context.NONE);

Transcriptie stoppen

Wanneer uw toepassing moet stoppen met luisteren naar de transcriptie, kunt u de StopTranscription-aanvraag gebruiken om Call Automation te laten weten dat ze geen transcriptiegegevens meer naar uw websocket verzenden.

// Option 1: Stop transcription with options
StopTranscriptionOptions stopTranscriptionOptions = new StopTranscriptionOptions()
    .setOperationContext("stopTranscription");

client.getCallConnection(callConnectionId)
    .getCallMedia()
    .stopTranscriptionWithResponse(stopTranscriptionOptions, Context.NONE);

// Alternative: Stop transcription without options
// client.getCallConnection(callConnectionId)
//     .getCallMedia()
//     .stopTranscription();

Een oproep maken en de transcriptiegegevens opgeven

Definieer de TranscriptionOptions voor ACS om op te geven wanneer de transcriptie moet worden gestart, de landinstelling voor transcriptie en de websocketverbinding voor het verzenden van het transcript.

const transcriptionOptions = {
    transportUrl: "",
    transportType: "websocket",
    locale: "en-US",
    startTranscription: false,
    speechRecognitionModelEndpointId: "YOUR_CUSTOM_SPEECH_RECOGNITION_MODEL_ID"
};

const options = {
    callIntelligenceOptions: {
        cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
    },
    transcriptionOptions: transcriptionOptions
};

console.log("Placing outbound call...");
acsClient.createCall(callInvite, process.env.CALLBACK_URI + "/api/callbacks", options);

Sentimentanalyse (Preview)

Houd de emotionele toon van gesprekken in realtime bij om interacties tussen klanten en agenten te ondersteunen en stelt supervisors in staat om zo nodig tussen te komen. Beschikbaar in openbare preview via createCall, answerCall en startTranscription.

Een aanroep maken waarvoor Sentimentanalyse is ingeschakeld

const transcriptionOptions = {
    transportUrl: "",
    transportType: "websocket",
    locale: "en-US",
    startTranscription: false,
    enableSentimentAnalysis: true,
    speechRecognitionModelEndpointId: "YOUR_CUSTOM_SPEECH_RECOGNITION_MODEL_ID"
};

const options = {
    callIntelligenceOptions: {
        cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
    },
    transcriptionOptions: transcriptionOptions
};

console.log("Placing outbound call...");
acsClient.createCall(callInvite, process.env.CALLBACK_URI + "/api/callbacks", options);

Een gesprek beantwoorden waarvoor Sentimentanalyse is ingeschakeld

const transcriptionOptions: TranscriptionOptions = {
  transportUrl: transportUrl,
  transportType: "websocket",
  startTranscription: true,
  enableSentimentAnalysis: true
};

const answerCallOptions: AnswerCallOptions = {
  callIntelligenceOptions: {
    cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
  },
  transcriptionOptions: transcriptionOptions,
  enableLoopbackAudio: true
};

await acsClient.answerCall(incomingCallContext, callbackUri, answerCallOptions);

PII-redactie (Preview)

Automatisch gevoelige informatie identificeren en maskeren, zoals namen, adressen of identificatienummers, om de naleving van privacy en regelgeving te waarborgen. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek beantwoorden met PII Redaction ingeschakeld

const transcriptionOptions: TranscriptionOptions = {
  transportUrl: transportUrl,
  transportType: "websocket",
  startTranscription: true,
  piiRedactionOptions: {
    enable: true,
    redactionType: "maskWithCharacter"
  }
};

const answerCallOptions: AnswerCallOptions = {
  callIntelligenceOptions: {
    cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
  },
  transcriptionOptions: transcriptionOptions,
  enableLoopbackAudio: true
};

await acsClient.answerCall(incomingCallContext, callbackUri, answerCallOptions);

Opmerking

Als piI-redaction is ingeschakeld, ontvangt u alleen de bewerkte tekst.

Realtime-taaldetectie (Preview)

Automatisch gesproken talen detecteren om natuurlijke, menselijke communicatie mogelijk te maken en handmatige taalselectie te elimineren. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek maken waarbij realtime taaldetectie is ingeschakeld

const transcriptionOptions: TranscriptionOptions = {
  transportUrl: transportUrl,
  transportType: "websocket",
  startTranscription: true,
  locales: ["es-ES", "en-US"]
};

const createCallOptions: CreateCallOptions = {
  callIntelligenceOptions: {
    cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
  },
  transcriptionOptions: transcriptionOptions,
  operationContext: "CreatPSTNCallContext",
  enableLoopbackAudio: true
};

Opmerking

Als u de taalidentificatie wilt stoppen nadat deze is gestart, gebruikt u de updateTranscription API en stelt u expliciet de taal in die u wilt gebruiken voor het transcript. Hierdoor wordt automatische taaldetectie uitgeschakeld en wordt transcriptie naar de opgegeven taal vergrendeld.

Verbinding maken met een Rooms-gesprek en transcriptiedetails opgeven

Als u verbinding maakt met een ACS-ruimte en transcriptie wilt gebruiken, configureert u de transcriptieopties als volgt:

const transcriptionOptions = {
    transportUri: "",
    locale: "en-US",
    transcriptionTransport: "websocket",
    startTranscription: false,
    speechRecognitionModelEndpointId: "YOUR_CUSTOM_SPEECH_RECOGNITION_MODEL_ID"
};

const callIntelligenceOptions = {
    cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
};

const connectCallOptions = {
    callIntelligenceOptions: callIntelligenceOptions,
    transcriptionOptions: transcriptionOptions
};

const callLocator = {
    id: roomId,
    kind: "roomCallLocator"
};

const connectResult = await client.connectCall(callLocator, callBackUri, connectCallOptions);

Transcriptie starten

Zodra u klaar bent om de transcriptie te starten, kunt u een expliciete aanroep naar Gespreksautomatisering maken om te beginnen met het transcriberen van de oproep.

const startTranscriptionOptions = {
    locale: "en-AU",
    operationContext: "startTranscriptionContext"
};

// Start transcription with options
await callMedia.startTranscription(startTranscriptionOptions);

// Alternative: Start transcription without options
// await callMedia.startTranscription();

Samenvattingen tijdens een gesprek ophalen (preview)

Verbeter uw gesprekswerkstromen met realtime samenvatting. Door samenvatting in te schakelen in uw transcriptieopties, kan ACS automatisch beknopte samenvattingen van middenoproepen genereren, inclusief beslissingen, actie-items en belangrijke discussiepunten, zonder te wachten tot de oproep is beëindigd. Dit helpt teams op elkaar afgestemd te blijven en snellere follow-ups mogelijk te maken tijdens livegesprekken.

const transcriptionOptions: TranscriptionOptions = {
  transportUrl: transportUrl,
  transportType: "websocket",
  startTranscription: true,
  summarizationOptions: {
    enableEndCallSummary: true,
    locale: "es-ES"
  }
};

const answerCallOptions: AnswerCallOptions = {
  callIntelligenceOptions: {
    cognitiveServicesEndpoint: process.env.COGNITIVE_SERVICES_ENDPOINT
  },
  transcriptionOptions: transcriptionOptions,
  enableLoopbackAudio: true
};

await acsClient.answerCall(incomingCallContext, callbackUri, answerCallOptions);

Extra headers:

De correlatie-id en de oproepverbindings-id zijn nu opgenomen in de WebSocket-headers voor verbeterde traceerbaarheid x-ms-call-correlation-id en x-ms-call-connection-id.

Transcriptiestroom ontvangen

Wanneer de transcriptie start, ontvangt uw websocket de payload van de transcriptiemetagegevens als het eerste pakket.

{
    "kind": "TranscriptionMetadata",
    "transcriptionMetadata": {
        "subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
        "locale": "en-us",
        "callConnectionId": "65c57654=f12c-4975-92a4-21668e61dd98",
        "correlationId": "65c57654=f12c-4975-92a4-21668e61dd98"
    }
}

Transcriptiegegevens ontvangen

Na de metagegevens zijn de volgende pakketten die uw websocket ontvangt TranscriptionData voor de getranscribeerde audio.

{
    "kind": "TranscriptionData",
    "transcriptionData": {
        "text": "Testing transcription.",
        "format": "display",
        "confidence": 0.695223331451416,
        "offset": 2516998782481234400,
        "words": [
            {
                "text": "testing",
                "offset": 2516998782481234400
            },
            {
                "text": "testing",
                "offset": 2516998782481234400
            }
        ],
        "participantRawID": "8:acs:",
        "resultStatus": "Final"
    }
}

Transcriptiestroom ontvangen met ingeschakelde AI-mogelijkheden (preview)

Wanneer transcriptie is ingeschakeld tijdens een aanroep, verzendt Azure Communication Services metagegevens die de configuratie en context van de transcriptiesessie beschrijven. Dit omvat details zoals de landinstelling, oproepverbindings-id, instellingen voor sentimentanalyse en voorkeuren voor piI-redaction. Ontwikkelaars kunnen deze nettolading gebruiken om de transcriptie-instellingen te controleren, configuraties te controleren of problemen op te lossen met betrekking tot realtime transcriptiefuncties die zijn verbeterd door AI.

{
  "kind": "TranscriptionMetadata",
  "transcriptionMetadata": {
    "subscriptionId": "863b5e55-de0d-4fc3-8e58-2d68e976b5ad",
    "locale": "en-US",
    "callConnectionId": "02009180-9dc2-429b-a3eb-d544b7b6a0e1",
    "correlationId": "62c8215b-5276-4d3c-bb6d-06a1b114651b",
    "speechModelEndpointId": null,
    "locales": [],
    "enableSentimentAnalysis": true,
    "piiRedactionOptions": {
      "enable": true,
      "redactionType": "MaskWithCharacter"
    }
  }
}

Transcriptiegegevens ontvangen met ingeschakelde AI-mogelijkheden (Preview)

Na het eerste metadatapakket gaat uw WebSocket-verbinding TranscriptionData-gebeurtenissen ontvangen voor elk segment van de getranscribeerde audio. Deze pakketten omvatten de getranscribeerde tekst, betrouwbaarheidsscore, timinginformatie en, indien ingeschakeld, sentimentanalyse en PII-redaction. Deze gegevens kunnen worden gebruikt voor het bouwen van realtime dashboards, het activeren van werkstromen of het analyseren van gespreksdynamiek tijdens het gesprek.

{
  "kind": "TranscriptionData",
  "transcriptionData": {
    "text": "My date of birth is *********.",
    "format": "display",
    "confidence": 0.8726407289505005,
    "offset": 309058340,
    "duration": 31600000,
    "words": [],
    "participantRawID": "4:+917020276722",
    "resultStatus": "Final",
    "sentimentAnalysisResult": {
      "sentiment": "neutral"
    }
  }
}

Transcriptiestroom verwerken in de websocket-server

import WebSocket from 'ws';
import { streamingData } from '@azure/communication-call-automation/src/util/streamingDataParser';

const wss = new WebSocket.Server({ port: 8081 });

wss.on('connection', (ws) => {
  console.log('Client connected');

  ws.on('message', (packetData) => {
    const decoder = new TextDecoder();
    const stringJson = decoder.decode(packetData);
    console.log("STRING JSON =>", stringJson);

    const response = streamingData(packetData);
    const kind = response?.kind;

    if (kind === "TranscriptionMetadata") {
      console.log("--------------------------------------------");
      console.log("Transcription Metadata");
      console.log("CALL CONNECTION ID: -->", response.callConnectionId);
      console.log("CORRELATION ID: -->", response.correlationId);
      console.log("LOCALE: -->", response.locale);
      console.log("SUBSCRIPTION ID: -->", response.subscriptionId);
      console.log("SPEECH MODEL ENDPOINT: -->", response.speechRecognitionModelEndpointId);
      console.log("IS SENTIMENT ANALYSIS ENABLED: -->", response.enableSentimentAnalysis);

      if (response.piiRedactionOptions) {
        console.log("PII REDACTION ENABLED: -->", response.piiRedactionOptions.enable);
        console.log("PII REDACTION TYPE: -->", response.piiRedactionOptions.redactionType);
      }

      if (response.locales) {
        response.locales.forEach((language) => {
          console.log("LOCALE DETECTED: -->", language);
        });
      }

      console.log("--------------------------------------------");
    } else if (kind === "TranscriptionData") {
      console.log("--------------------------------------------");
      console.log("Transcription Data");
      console.log("TEXT: -->", response.text);
      console.log("FORMAT: -->", response.format);
      console.log("CONFIDENCE: -->", response.confidence);
      console.log("OFFSET IN TICKS: -->", response.offsetInTicks);
      console.log("DURATION IN TICKS: -->", response.durationInTicks);
      console.log("RESULT STATE: -->", response.resultState);

      if (response.participant?.phoneNumber) {
        console.log("PARTICIPANT PHONE NUMBER: -->", response.participant.phoneNumber);
      }

      if (response.participant?.communicationUserId) {
        console.log("PARTICIPANT USER ID: -->", response.participant.communicationUserId);
      }

      if (response.words?.length) {
        response.words.forEach((word) => {
          console.log("WORD TEXT: -->", word.text);
          console.log("WORD DURATION IN TICKS: -->", word.durationInTicks);
          console.log("WORD OFFSET IN TICKS: -->", word.offsetInTicks);
        });
      }

      if (response.sentimentAnalysisResult) {
        console.log("SENTIMENT: -->", response.sentimentAnalysisResult.sentiment);
      }

      console.log("LANGUAGE IDENTIFIED: -->", response.languageIdentified);
      console.log("--------------------------------------------");
    }
  });

  ws.on('close', () => {
    console.log('Client disconnected');
  });
});

console.log('WebSocket server running on port 8081');

Transcriptie bijwerken

In situaties waarin gebruikers in uw toepassing hun voorkeurstaal kunnen selecteren, kunt u ook de transcriptie in die taal vastleggen. Als u deze taak wilt uitvoeren, kunt u met de Call Automation SDK de transcriptielocatie bijwerken.

async function updateTranscriptionAsync() {
  const options: UpdateTranscriptionOptions = {
operationContext: "updateTranscriptionContext",
speechRecognitionModelEndpointId: "YOUR_CUSTOM_SPEECH_RECOGNITION_MODEL_ID"
  };
  await acsClient
.getCallConnection(callConnectionId)
.getCallMedia()
.updateTranscription("en-au", options);
}

Transcriptie stoppen

Wanneer uw toepassing moet stoppen met luisteren naar de transcriptie, kunt u de StopTranscription-aanvraag gebruiken om Call Automation te laten weten dat ze geen transcriptiegegevens meer naar uw websocket verzenden.

const stopTranscriptionOptions = {
    operationContext: "stopTranscriptionContext"
};

// Stop transcription with options
await callMedia.stopTranscription(stopTranscriptionOptions);

// Alternative: Stop transcription without options
// await callMedia.stopTranscription();

Een oproep maken en de transcriptiegegevens opgeven

Definieer de TranscriptionOptions voor ACS om op te geven wanneer de transcriptie moet worden gestart, de landinstelling voor transcriptie en de websocketverbinding voor het verzenden van het transcript.

transcription_options = TranscriptionOptions(
    transport_url="WEBSOCKET_URI_HOST",
    transport_type=TranscriptionTransportType.WEBSOCKET,
    locale="en-US",
    start_transcription=False,
    #Only add the SpeechRecognitionModelEndpointId if you have a custom speech model you would like to use
    speech_recognition_model_endpoint_id = "YourCustomSpeechRecognitionModelEndpointId"
);
)

call_connection_properties = call_automation_client.create_call(
    target_participant,
    CALLBACK_EVENTS_URI,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    source_caller_id_number=source_caller,
    transcription=transcription_options
)

Sentimentanalyse (Preview)

Houd de emotionele toon van gesprekken in realtime bij om interacties tussen klanten en agenten te ondersteunen en stelt supervisors in staat om zo nodig tussen te komen. Beschikbaar in openbare preview via createCall, answerCall en startTranscription.

Een aanroep maken waarvoor Sentimentanalyse is ingeschakeld

transcription_options = TranscriptionOptions(
    transport_url=self.transport_url,
    transport_type=StreamingTransportType.WEBSOCKET,
    locale="en-US",
    start_transcription=False,
    enable_sentiment_analysis=True
)

call_connection_properties = await call_automation_client.create_call(
    target_participant=[target_participant],
    callback_url=CALLBACK_EVENTS_URI,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    source_caller_id_number=source_caller,
    transcription=transcription_options
)

Een gesprek beantwoorden waarvoor Sentimentanalyse is ingeschakeld

transcription_options = TranscriptionOptions(
    transport_url=self.transport_url,
    transport_type=StreamingTransportType.WEBSOCKET,
    locale="en-US",
    start_transcription=False,
    enable_sentiment_analysis=True
)

answer_call_result = await call_automation_client.answer_call(
    incoming_call_context=incoming_call_context,
    transcription=transcription_options,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    callback_url=callback_uri,
    enable_loopback_audio=True,
    operation_context="answerCallContext"
)

PII-redactie (Preview)

Automatisch gevoelige informatie identificeren en maskeren, zoals namen, adressen of identificatienummers, om de naleving van privacy en regelgeving te waarborgen. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek beantwoorden met PII Redaction ingeschakeld

transcription_options = TranscriptionOptions(
    transport_url=self.transport_url,
    transport_type=StreamingTransportType.WEBSOCKET,
    locale=["en-US", "es-ES"],
    start_transcription=False,
    pii_redaction=PiiRedactionOptions(
        enable=True,
        redaction_type=RedactionType.MASK_WITH_CHARACTER
    )
)

answer_call_result = await call_automation_client.answer_call(
    incoming_call_context=incoming_call_context,
    transcription=transcription_options,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    callback_url=callback_uri,
    enable_loopback_audio=True,
    operation_context="answerCallContext"
)

Opmerking

Als piI-redaction is ingeschakeld, ontvangt u alleen de bewerkte tekst.

Realtime-taaldetectie (Preview)

Automatisch gesproken talen detecteren om natuurlijke, menselijke communicatie mogelijk te maken en handmatige taalselectie te elimineren. Beschikbaar in createCall, answerCall en startTranscription.

Een gesprek maken waarbij realtime taaldetectie is ingeschakeld

transcription_options = TranscriptionOptions(
    transport_url=self.transport_url,
    transport_type=StreamingTransportType.WEBSOCKET,
    locale=["en-US", "es-ES","hi-IN"],
    start_transcription=False,
    enable_sentiment_analysis=True,
)

call_connection_properties = await call_automation_client.create_call(
    target_participant=[target_participant],
    callback_url=CALLBACK_EVENTS_URI,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    source_caller_id_number=source_caller,
    transcription=transcription_options
)

Opmerking

Als u de taalidentificatie wilt stoppen nadat deze is gestart, gebruikt u de updateTranscription API en stelt u expliciet de taal in die u wilt gebruiken voor het transcript. Hierdoor wordt automatische taaldetectie uitgeschakeld en wordt transcriptie naar de opgegeven taal vergrendeld.

Verbinding maken met een Rooms-gesprek en transcriptiedetails opgeven

Als u verbinding maakt met een ACS-ruimte en transcriptie wilt gebruiken, configureert u de transcriptieopties als volgt:

transcription_options = TranscriptionOptions(
    transport_url="",
    transport_type=TranscriptionTransportType.WEBSOCKET,
    locale="en-US",
    start_transcription=False,
    #Only add the SpeechRecognitionModelEndpointId if you have a custom speech model you would like to use
    speech_recognition_model_endpoint_id = "YourCustomSpeechRecognitionModelEndpointId"
)

connect_result = client.connect_call(
    room_id="roomid",
    CALLBACK_EVENTS_URI,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    operation_context="connectCallContext",
    transcription=transcription_options
)

Transcriptie starten

Zodra u klaar bent om de transcriptie te starten, kunt u een expliciete aanroep naar Gespreksautomatisering maken om te beginnen met het transcriberen van de oproep.

# Start transcription without options
call_connection_client.start_transcription()

# Option 1: Start transcription with locale and operation context
# call_connection_client.start_transcription(locale="en-AU", operation_context="startTranscriptionContext")

# Option 2: Start transcription with operation context
# call_connection_client.start_transcription(operation_context="startTranscriptionContext")

Samenvattingen tijdens een gesprek ophalen (preview)

Verbeter uw gesprekswerkstromen met realtime samenvatting. Door samenvatting in te schakelen in uw transcriptieopties, kan ACS automatisch beknopte samenvattingen van middenoproepen genereren, inclusief beslissingen, actie-items en belangrijke discussiepunten, zonder te wachten tot de oproep is beëindigd. Dit helpt teams op elkaar afgestemd te blijven en snellere follow-ups mogelijk te maken tijdens livegesprekken.

transcription_options = TranscriptionOptions(
    transport_url=self.transport_url,
    transport_type=StreamingTransportType.WEBSOCKET,
    locale="en-US",
    start_transcription=False,
    summarization=SummarizationOptions(
        enable_end_call_summary=True,
        locale="en-US"
    )
)

answer_call_result = await call_automation_client.answer_call(
    incoming_call_context=incoming_call_context,
    transcription=transcription_options,
    cognitive_services_endpoint=COGNITIVE_SERVICES_ENDPOINT,
    callback_url=callback_uri,
    enable_loopback_audio=True,
    operation_context="answerCallContext"
)


await call_connection_client.summarize_call(
    operation_context=self.operation_context,
    operation_callback_url=self.operation_callback_url,
    summarization=transcription_options.summarization
)

Extra headers:

De correlatie-id en de oproepverbindings-id zijn nu opgenomen in de WebSocket-headers voor verbeterde traceerbaarheid x-ms-call-correlation-id en x-ms-call-connection-id.

Transcriptiestroom ontvangen

Wanneer de transcriptie start, ontvangt uw websocket de payload van de transcriptiemetagegevens als het eerste pakket.

{
    "kind": "TranscriptionMetadata",
    "transcriptionMetadata": {
        "subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
        "locale": "en-us",
        "callConnectionId": "65c57654=f12c-4975-92a4-21668e61dd98",
        "correlationId": "65c57654=f12c-4975-92a4-21668e61dd98"
    }
}

Transcriptiegegevens ontvangen

Na de metagegevens zullen de volgende pakketten die uw websocket zal ontvangen, "TranscriptionData" zijn voor de getranscribeerde audio.

{
    "kind": "TranscriptionData",
    "transcriptionData": {
        "text": "Testing transcription.",
        "format": "display",
        "confidence": 0.695223331451416,
        "offset": 2516998782481234400,
        "words": [
            {
                "text": "testing",
                "offset": 2516998782481234400
            },
            {
                "text": "testing",
                "offset": 2516998782481234400
            }
        ],
        "participantRawID": "8:acs:",
        "resultStatus": "Final"
    }
}

Transcriptiestroom ontvangen met ingeschakelde AI-mogelijkheden (preview)

Wanneer transcriptie is ingeschakeld tijdens een aanroep, verzendt Azure Communication Services metagegevens die de configuratie en context van de transcriptiesessie beschrijven. Dit omvat details zoals de landinstelling, oproepverbindings-id, instellingen voor sentimentanalyse en voorkeuren voor piI-redaction. Ontwikkelaars kunnen deze nettolading gebruiken om de transcriptie-instellingen te controleren, configuraties te controleren of problemen op te lossen met betrekking tot realtime transcriptiefuncties die zijn verbeterd door AI.

{
  "kind": "TranscriptionMetadata",
  "transcriptionMetadata": {
    "subscriptionId": "863b5e55-de0d-4fc3-8e58-2d68e976b5ad",
    "locale": "en-US",
    "callConnectionId": "02009180-9dc2-429b-a3eb-d544b7b6a0e1",
    "correlationId": "62c8215b-5276-4d3c-bb6d-06a1b114651b",
    "speechModelEndpointId": null,
    "locales": [],
    "enableSentimentAnalysis": true,
    "piiRedactionOptions": {
      "enable": true,
      "redactionType": "MaskWithCharacter"
    }
  }
}

Transcriptiegegevens ontvangen met ingeschakelde AI-mogelijkheden (Preview)

Na het eerste metadatapakket gaat uw WebSocket-verbinding TranscriptionData-gebeurtenissen ontvangen voor elk segment van de getranscribeerde audio. Deze pakketten omvatten de getranscribeerde tekst, betrouwbaarheidsscore, timinginformatie en, indien ingeschakeld, sentimentanalyse en PII-redaction. Deze gegevens kunnen worden gebruikt voor het bouwen van realtime dashboards, het activeren van werkstromen of het analyseren van gespreksdynamiek tijdens het gesprek.

{
  "kind": "TranscriptionData",
  "transcriptionData": {
    "text": "My date of birth is *********.",
    "format": "display",
    "confidence": 0.8726407289505005,
    "offset": 309058340,
    "duration": 31600000,
    "words": [],
    "participantRawID": "4:+917020276722",
    "resultStatus": "Final",
    "sentimentAnalysisResult": {
      "sentiment": "neutral"
    }
  }
}

Transcriptiestroom verwerken in de websocket-server

import asyncio
import json
import websockets
from azure.communication.callautomation._shared.models import identifier_from_raw_id

async def handle_client(websocket, path):
    print("Client connected")
    try:
        async for message in websocket:
            json_object = json.loads(message)
            kind = json_object['kind']
            if kind == 'TranscriptionMetadata':
                print("Transcription metadata")
                print("-------------------------")
                print("Subscription ID:", json_object['transcriptionMetadata']['subscriptionId'])
                print("Locale:", json_object['transcriptionMetadata']['locale'])
                print("Call Connection ID:", json_object['transcriptionMetadata']['callConnectionId'])
                print("Correlation ID:", json_object['transcriptionMetadata']['correlationId'])
                print("Locales:", json_object['transcriptionMetadata']['locales']) 
                print("PII Redaction Options:", json_object['transcriptionMetadata']['piiRedactionOptions']) 
            if kind == 'TranscriptionData':
                participant = identifier_from_raw_id(json_object['transcriptionData']['participantRawID'])
                word_data_list = json_object['transcriptionData']['words']
                print("Transcription data")
                print("-------------------------")
                print("Text:", json_object['transcriptionData']['text'])
                print("Format:", json_object['transcriptionData']['format'])
                print("Confidence:", json_object['transcriptionData']['confidence'])
                print("Offset:", json_object['transcriptionData']['offset'])
                print("Duration:", json_object['transcriptionData']['duration'])
                print("Participant:", participant.raw_id)
                print("Result Status:", json_object['transcriptionData']['resultStatus']) 
                print("Sentiment Analysis Result:", json_object['transcriptionData']['sentimentAnalysisResult']) 
                print("Result Status:", json_object['transcriptionData']['resultStatus'])
                for word in word_data_list:
                    print("Word:", word['text'])
                    print("Offset:", word['offset'])
                    print("Duration:", word['duration'])
            
    except websockets.exceptions.ConnectionClosedOK:
        print("Client disconnected")
    except websockets.exceptions.ConnectionClosedError as e:
        print("Connection closed with error: %s", e)
    except Exception as e:
        print("Unexpected error: %s", e)

start_server = websockets.serve(handle_client, "localhost", 8081)

print('WebSocket server running on port 8081')

asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()

Transcriptie bijwerken

In situaties waarin gebruikers in uw toepassing hun voorkeurstaal kunnen selecteren, kunt u ook de transcriptie in die taal vastleggen. Als u deze taak wilt uitvoeren, kunt u met de Call Automation SDK de transcriptielocatie bijwerken.

await call_automation_client.get_call_connection(
    call_connection_id=call_connection_id
).update_transcription(
    operation_context="UpdateTranscriptionContext",
    locale="en-au",
    #Only add the SpeechRecognitionModelEndpointId if you have a custom speech model you would like to use
    speech_recognition_model_endpoint_id = "YourCustomSpeechRecognitionModelEndpointId"
)

Transcriptie stoppen

Wanneer uw toepassing moet stoppen met luisteren naar de transcriptie, kunt u de StopTranscription-aanvraag gebruiken om Call Automation te laten weten dat ze geen transcriptiegegevens meer naar uw websocket verzenden.

# Stop transcription without options
call_connection_client.stop_transcription()

# Alternative: Stop transcription with operation context
# call_connection_client.stop_transcription(operation_context="stopTranscriptionContext")

Gebeurteniscodes

Gebeurtenis code subcode Bericht
Starten van transcriptie 200 0 De actie is voltooid.
TranscriptieGestopt 200 0 De actie is voltooid.
TranscripteBijgewerkt 200 0 De actie is voltooid.
TranscriptieMislukt 400 8581 De actie is mislukt, StreamUrl is niet geldig.
TranscriptieMislukt 400 8565 De actie is mislukt vanwege een ongeldige aanvraag voor Cognitive Services. Controleer de invoerparameters.
TranscriptieMislukt 400 8565 De actie is mislukt vanwege een time-out van een aanvraag voor Cognitive Services. Probeer het later opnieuw of controleer op eventuele problemen met de service.
TranscriptieMislukt 400 8605 Aangepast spraakherkenningsmodel voor transcriptie wordt niet ondersteund.
TranscriptieMislukt 400 8523 Ongeldige aanvraag, lokale instellingen ontbreken.
TranscriptieMislukt 400 8523 Ongeldige aanvraag, alleen landinstellingen die regiogegevens bevatten, worden ondersteund.
TranscriptieMislukt 405 8520 Transcriptiefunctionaliteit wordt momenteel niet ondersteund.
TranscriptieMislukt 405 8520 UpdateTranscription wordt niet ondersteund voor verbinding die is gemaakt met de Connect-interface.
TranscriptieMislukt 400 8528 Actie is ongeldig, oproep is al beëindigd.
TranscriptieMislukt 405 8520 De functionaliteit voor het bijwerken van transcriptie wordt momenteel niet ondersteund.
TranscriptieMislukt 405 8522 Aanvraag is niet toegestaan wanneer transcriptie-URL niet is ingesteld tijdens het instellen van oproepen.
TranscriptieMislukt 405 8522 Aanvraag is niet toegestaan wanneer Cognitive Service-configuratie niet is ingesteld tijdens het instellen van oproepen.
TranscriptieMislukt 400 8501 De actie is ongeldig wanneer de aanroep niet de status Ingesteld heeft.
TranscriptieMislukt 401 8565 De actie is mislukt vanwege een Cognitive Services-verificatiefout. Controleer uw autorisatie-invoer en controleer of deze juist is.
TranscriptieMislukt 403 8565 De actie is mislukt vanwege een verboden aanvraag voor Cognitive Services. Controleer de status van uw abonnement en controleer of het actief is.
TranscriptieMislukt 429 8565 Actie is mislukt, aanvragen hebben het aantal toegestane gelijktijdige aanvragen voor het cognitive services-abonnement overschreden.
TranscriptieMislukt 500 8578 De actie is mislukt, kan geen WebSocket-verbinding tot stand brengen.
TranscriptieMislukt 500 8580 De actie is mislukt, de transcriptieservice is afgesloten.
TranscriptieMislukt 500 8579 Actie is mislukt, transcriptie is geannuleerd.
TranscriptieMislukt 500 9999 Onbekende interne serverfout.

Bekende problemen

  • Voor 1-op-1-gesprekken met ACS-gebruikers waarbij client-SDK's worden gebruikt, wordt "startTranscription = True" momenteel niet ondersteund.