快速入門:通話後的轉譯和分析

語言服務文件 | Language Studio | 語音服務文件 | Speech Studio

在本 C# 快速入門中,您會針對通話中心轉譯執行情感分析和交談摘要。 此範例會自動識別、分類和修訂敏感性資訊。 此快速入門會實作使用 Azure 認知語音Azure 認知語言服務功能的跨服務案例。

提示

請嘗試使用 Language StudioSpeech Studio 來取得如何使用語言和語音服務分析通話中心交談的示範。

若要使用無程式碼方法將客服中心轉譯解決方案部署到 Azure,請嘗試擷取用戶端

快速入門中會使用下列適用于語音功能的 Azure AI 服務:

  • 批次轉譯:提交一批音訊檔案以進行轉譯。
  • 說話者分離:透過對單聲道 16khz 16 位元 PCM WAV 檔案進行分辨來分離多個說話者。

語言服務提供下列所使用的功能:

必要條件

重要

此快速入門需要存取交談摘要。 若要取得存取,您必須提交線上要求 (英文) 並取得核准。

此快速入門中的 --languageKey--languageEndpoint 值必須對應至位於交談摘要 API (部分機器翻譯) 所支援的下列其中一個區域中的資源:eastusnortheurope,以及 uksouth

使用 C# 執行通話後轉譯分析

遵循下列步驟來建置並執行通話後轉譯分析快速入門程式碼範例。

  1. 從 GitHub 複製 scenarios/csharp/dotnetcore/call-center/ (英文) 範例檔案。 如果您已安裝 Git (英文),請開啟命令提示字元,然後執行 git clone 命令以下載語音 SDK 範例存放庫。

    git clone https://github.com/Azure-Samples/cognitive-services-speech-sdk.git
    
  2. 開啟命令提示字元,並變更至專案目錄。

    cd <your-local-path>/scenarios/csharp/dotnetcore/call-center/call-center/
    
  3. 使用 .NET CLI 建置專案。

    dotnet build
    
  4. 使用您慣用的命令列引數執行應用程式。 如需可用選項,請參閱使用方式和引數

    以下是從 GitHub (英文) 的範例音訊檔案轉譯的範例:

    dotnet run --languageKey YourResourceKey --languageEndpoint YourResourceEndpoint --speechKey YourResourceKey --speechRegion YourResourceRegion --input "https://github.com/Azure-Samples/cognitive-services-speech-sdk/raw/master/scenarios/call-center/sampledata/Call1_separated_16k_health_insurance.wav" --stereo  --output summary.json
    

    如果您已經可作為輸入的轉譯,以下是只需要語言資源的範例:

    dotnet run --languageKey YourResourceKey --languageEndpoint YourResourceEndpoint --jsonInput "YourTranscriptionFile.json" --stereo  --output summary.json
    

    將 取代 YourResourceKey 為您的 Azure AI 服務資源金鑰、將 取代 YourResourceRegion 為您的 Azure AI 服務資源 區域 (例如 eastus) ,並將 取代 YourResourceEndpoint 為您的 Azure AI 服務端點。 請確定 --input--output 指定的路徑有效。 否則您必須變更路徑。

    重要

    完成時,請記得從程式碼中移除金鑰,且不要公開張貼金鑰。 在生產環境中,請使用安全的方式來儲存和存取您的認證,例如 Azure Key Vault。 如需詳細資訊,請參閱 Azure AI 服務 安全性 文章。

檢查結果

主控台輸出會顯示完整的交談和摘要。 以下是整體摘要的範例,其中包含為了簡潔起見所做的修訂:

Conversation summary:
    issue: Customer wants to sign up for insurance.
    resolution: Customer was advised that customer would be contacted by the insurance company.

如果您指定--output FILE選擇性引數,結果的 JSON 版本會寫入檔案。 檔案輸出是來自批次轉譯 (語音)、情感 (語言) 和交談摘要 (語言) API 的 JSON 回應組合。

transcription 屬性包含 JSON 物件,其中包含與批次轉譯合併的情感分析結果。 以下是範例,其中包含為了簡潔起見所做的修訂:

{
    "source": "https://github.com/Azure-Samples/cognitive-services-speech-sdk/raw/master/scenarios/call-center/sampledata/Call1_separated_16k_health_insurance.wav",
// Example results redacted for brevity
        "nBest": [
          {
            "confidence": 0.77464247,
            "lexical": "hello thank you for calling contoso who am i speaking with today",
            "itn": "hello thank you for calling contoso who am i speaking with today",
            "maskedITN": "hello thank you for calling contoso who am i speaking with today",
            "display": "Hello, thank you for calling Contoso. Who am I speaking with today?",
            "sentiment": {
              "positive": 0.78,
              "neutral": 0.21,
              "negative": 0.01
            }
          },
        ]
// Example results redacted for brevity
}   

conversationAnalyticsResults 屬性包含 JSON 物件,其中包含交談 PII 和交談摘要分析的結果。 以下是範例,其中包含為了簡潔起見所做的修訂:

{
  "conversationAnalyticsResults": {
    "conversationSummaryResults": {
      "conversations": [
        {
          "id": "conversation1",
          "summaries": [
            {
              "aspect": "issue",
              "text": "Customer wants to sign up for insurance"
            },
            {
              "aspect": "resolution",
              "text": "Customer was advised that customer would be contacted by the insurance company"
            }
          ],
          "warnings": []
        }
      ],
      "errors": [],
      "modelVersion": "2022-05-15-preview"
    },
    "conversationPiiResults": {
      "combinedRedactedContent": [
        {
          "channel": "0",
          "display": "Hello, thank you for calling Contoso. Who am I speaking with today? Hi, ****. Uh, are you calling because you need health insurance?", // Example results redacted for brevity
          "itn": "hello thank you for calling contoso who am i speaking with today hi **** uh are you calling because you need health insurance", // Example results redacted for brevity
          "lexical": "hello thank you for calling contoso who am i speaking with today hi **** uh are you calling because you need health insurance" // Example results redacted for brevity
        },
        {
          "channel": "1",
          "display": "Hi, my name is **********. I'm trying to enroll myself with Contoso. Yes. Yeah, I'm calling to sign up for insurance.", // Example results redacted for brevity
          "itn": "hi my name is ********** i'm trying to enroll myself with contoso yes yeah i'm calling to sign up for insurance", // Example results redacted for brevity
          "lexical": "hi my name is ********** i'm trying to enroll myself with contoso yes yeah i'm calling to sign up for insurance" // Example results redacted for brevity
        }
      ],
      "conversations": [
        {
          "id": "conversation1",
          "conversationItems": [
            {
              "id": "0",
              "redactedContent": {
                "itn": "hello thank you for calling contoso who am i speaking with today",
                "lexical": "hello thank you for calling contoso who am i speaking with today",
                "text": "Hello, thank you for calling Contoso. Who am I speaking with today?"
              },
              "entities": [],
              "channel": "0",
              "offset": "PT0.77S"
            },
            {
              "id": "1",
              "redactedContent": {
                "itn": "hi my name is ********** i'm trying to enroll myself with contoso",
                "lexical": "hi my name is ********** i'm trying to enroll myself with contoso",
                "text": "Hi, my name is **********. I'm trying to enroll myself with Contoso."
              },
              "entities": [
                {
                  "text": "Mary Rondo",
                  "category": "Name",
                  "offset": 15,
                  "length": 10,
                  "confidenceScore": 0.97
                }
              ],
              "channel": "1",
              "offset": "PT4.55S"
            },
            {
              "id": "2",
              "redactedContent": {
                "itn": "hi **** uh are you calling because you need health insurance",
                "lexical": "hi **** uh are you calling because you need health insurance",
                "text": "Hi, ****. Uh, are you calling because you need health insurance?"
              },
              "entities": [
                {
                  "text": "Mary",
                  "category": "Name",
                  "offset": 4,
                  "length": 4,
                  "confidenceScore": 0.93
                }
              ],
              "channel": "0",
              "offset": "PT9.55S"
            },
            {
              "id": "3",
              "redactedContent": {
                "itn": "yes yeah i'm calling to sign up for insurance",
                "lexical": "yes yeah i'm calling to sign up for insurance",
                "text": "Yes. Yeah, I'm calling to sign up for insurance."
              },
              "entities": [],
              "channel": "1",
              "offset": "PT13.09S"
            },
// Example results redacted for brevity
          ],
          "warnings": []
        }
      ]
    }
  }
}

使用方式和引數

使用方式:call-center -- [...]

重要

您可以使用多服務資源,或個別語言資源。 不管是哪一個情況,--languageKey--languageEndpoint 值都必須對應至位於交談摘要 API (部分機器翻譯) 所支援的下列其中一個區域中的資源:eastusnortheurope,以及 uksouth

連線選項包括:

  • --speechKey KEY:建立金鑰。 具有來自 URL 選項之 --input 的音訊轉譯的必要項目。

  • --speechRegion REGION:建立區域。 具有來自 URL 選項之 --input 的音訊轉譯的必要項目。 範例:eastusnortheurope

  • --languageKey KEY:建立資源金鑰。 必要。

  • --languageEndpoint ENDPOINT:建立資源端點。 必要。 範例: https://YourResourceName.cognitiveservices.azure.com

輸入選項包括:

  • --input URL:來自 URL 的輸入音訊。 您必須設定 --input--jsonInput 選項。
  • --jsonInput FILE:輸入來自 FILE 的現有批次轉譯 JSON 結果。 使用此選項時,您只需要語言資源來處理您已經擁有的轉譯。 使用此選項時,您不需要音訊檔案或語音資源。 覆寫 --input。 您必須設定 --input--jsonInput 選項。
  • --stereo:表示透過「輸入 URL」的音訊應為立體聲格式。 如果未指定立體聲,系統會假設使用的是單聲道 16khz 16 位元 PCM WAV 檔案。 會針對單聲道檔案進行分辨來分離多個說話者。 不支援對立體化檔案進行分辨,因為 2 聲道立體聲檔案的每個聲道都應該只有其中一個說話者的聲音。
  • --certificate:PEM 憑證檔案。 C++ 的必要項目。

語言選項包括:

  • --language LANGUAGE:用於情感分析和交談分析的語言。 此值應該是兩個字母的 ISO 639-1 代碼。 預設值是 en
  • --locale LOCALE:用於音訊批次轉譯的地區設定。 預設值是 en-US

輸出選項包括:

  • --help:顯示使用方式說明並停止
  • --output FILE:將 JSON 格式的轉譯、情感、交談 PII 和交談摘要輸出至文字檔。 如需詳細資訊,請參閱輸出範例

清除資源

您可以使用Azure 入口網站Azure 命令列介面 (CLI) 來移除您所建立的 Azure AI 服務資源。

下一步