安裝和執行語音服務容器(預覽)Install and run Speech service containers (Preview)

容器可讓您在自己的環境中執行某些語音服務 Api。Containers enable you to run some of the Speech service APIs in your own environment. 容器非常適合用於特定的安全性和資料控管需求。Containers are great for specific security and data governance requirements. 在本文中,您將瞭解如何下載、安裝及執行語音容器。In this article you'll learn how to download, install, and run a Speech container.

語音容器可讓客戶建立已針對健全的雲端功能和邊緣位置優化的語音應用程式架構。Speech containers enable customers to build a speech application architecture that is optimized for both robust cloud capabilities and edge locality. 有四個不同的容器可供使用。There are four different containers available. 這兩個標準容器是語音轉換文字文字轉換語音The two standard containers are Speech-to-text and Text-to-speech. 這兩個自訂容器是自訂的語音轉換文字自訂文字轉換語音The two custom containers are Custom Speech-to-text and Custom Text-to-speech. 語音容器與雲端式 Azure 語音服務具有相同的定價Speech containers have the same pricing as the cloud-based Azure Speech Services.

重要

所有語音容器目前都是公開「閘道」預覽的一部分。All speech containers are currently offered as part of a Public "Gated" Preview. 當語音容器進行公開上市(GA)時,將會發出公告。An announcement will be made when speech containers progress to General Availability (GA).

函式Function 功能Features 最新Latest
語音轉文字Speech-to-text 使用中繼結果分析情感和可將連續即時語音或批次音訊錄製。Analyzes sentiment and transcribes continuous real-time speech or batch audio recordings with intermediate results. 2.2.02.2.0
自訂語音轉換文字Custom Speech-to-text 使用自定義語音入口網站中的自訂模型,將連續即時語音或批次錄音可將為具有中繼結果的文字。Using a custom model from the Custom Speech portal, transcribes continuous real-time speech or batch audio recordings into text with intermediate results. 2.2.02.2.0
文字轉換語音Text-to-speech 使用純文字輸入或語音合成標記語言(SSML),將文字轉換成自然發音的語音。Converts text to natural-sounding speech with plain text input or Speech Synthesis Markup Language (SSML). 1.4.01.4.0
自訂文字轉換語音Custom Text-to-speech 使用自定義語音入口網站中的自訂模型,以純文字輸入或語音合成標記語言(SSML)將文字轉換成自然發音的語音。Using a custom model from the Custom Voice portal, converts text to natural-sounding speech with plain text input or Speech Synthesis Markup Language (SSML). 1.4.01.4.0

如果您沒有 Azure 訂用帳戶,請在開始前建立免費帳戶If you don't have an Azure subscription, create a free account before you begin.

PrerequisitesPrerequisites

使用語音容器之前的必要條件如下:The following prerequisites before using Speech containers:

必要Required 目的Purpose
Docker 引擎Docker Engine 您必須在主機電腦上安裝 Docker 引擎。You need the Docker Engine installed on a host computer. Docker 提供可在 macOSWindowsLinux 上設定 Docker 環境的套件。Docker provides packages that configure the Docker environment on macOS, Windows, and Linux. 如需 Docker 和容器基本概念的入門,請參閱 Docker 概觀 (英文)。For a primer on Docker and container basics, see the Docker overview.

Docker 必須設定為允許容器與 Azure 連線,以及傳送帳單資料至 Azure。Docker must be configured to allow the containers to connect with and send billing data to Azure.

在 Windows 上,也必須將 Docker 設定為支援 Linux 容器。On Windows, Docker must also be configured to support Linux containers.

熟悉 DockerFamiliarity with Docker 您應具備對 Docker 概念 (例如登錄、存放庫、容器和容器映像等) 的基本了解,以及基本 docker 命令的知識。You should have a basic understanding of Docker concepts, like registries, repositories, containers, and container images, as well as knowledge of basic docker commands.
語音資源Speech resource 若要使用這些容器,您必須具備:In order to use these containers, you must have:

Azure_語音_資源,用來取得相關聯的 API 金鑰和端點 URI。An Azure Speech resource to get the associated API key and endpoint URI. 這兩個值都可在 Azure 入口網站的 [語音總覽] 和 [金鑰] 頁面上取得。Both values are available on the Azure portal's Speech Overview and Keys pages. 這兩者都是啟動容器的必要項。They are both required to start the container.

{API_KEY}: [金鑰] 頁面上有兩個可用的資源金鑰之一{API_KEY}: One of the two available resource keys on the Keys page

{ENDPOINT_URI}: [總覽] 頁面上所提供的端點{ENDPOINT_URI}: The endpoint as provided on the Overview page

要求存取容器登錄Request access to the container registry

填寫並提交要求表單,以要求容器的存取權。Fill out and submit the request form to request access to the container.

該表格需要有關您本身、您的公司,以及您將會使用該容器之使用者情節的資訊。The form requests information about you, your company, and the user scenario for which you'll use the container. 提交表單之後,Azure 認知服務小組會進行審查,以確保您符合存取私人容器登錄的準則。After you've submitted the form, the Azure Cognitive Services team reviews it to ensure that you meet the criteria for access to the private container registry.

重要

在表單中,您必須使用與 Microsoft 帳戶(MSA)或 Azure Active Directory (Azure AD)帳戶相關聯的電子郵件地址。You must use an email address that's associated with either a Microsoft Account (MSA) or Azure Active Directory (Azure AD) account in the form.

如果您的要求已通過核准,您會收到一封電子郵件,其中包含說明如何取得認證和存取私人容器登錄的指示。If your request is approved, you'll receive an email with instructions that describe how to obtain your credentials and access the private container registry.

使用 Docker CLI 來驗證私人容器登錄Use the Docker CLI to authenticate the private container registry

您可以透過數種方式使用認知服務容器的私人容器登錄進行驗證,但從命令列建議的方法是使用DOCKER CLIYou can authenticate with the private container registry for Cognitive Services Containers in any of several ways, but the recommended method from the command line is to use the Docker CLI.

如下列範例所示,使用 docker login命令來登入containerpreview.azurecr.io認知服務容器的私人容器登錄。Use the docker login command, as shown in the following example, to log in to containerpreview.azurecr.io, the private container registry for Cognitive Services Containers. 將* <username> 取代為使用者名稱和 <密碼> * ,並使用您從 Azure 認知服務小組收到的認證所提供的密碼。Replace <username> with the user name and <password> with the password that's provided in the credentials you received from the Azure Cognitive Services team.

docker login containerpreview.azurecr.io -u <username> -p <password>

如果您已在文字檔中保護您的認證,則可以使用cat命令將該文字檔的內容串連至docker login命令,如下列範例所示。If you've secured your credentials in a text file, you can concatenate the contents of that text file, by using the cat command, to the docker login command, as shown in the following example. 將* <passwordFile> 取代為包含密碼的文字檔路徑和名稱,並 < > *以您的認證中提供的使用者名稱取代 username。Replace <passwordFile> with the path and name of the text file that contains the password and <username> with the user name that's provided in your credentials.

cat <passwordFile> | docker login containerpreview.azurecr.io -u <username> --password-stdin

正在搜集必要的參數Gathering required parameters

所有必要的認知服務容器都有三個主要參數。There are three primary parameters for all Cognitive Services' containers that are required. 使用者授權合約(EULA)必須存在,且值為acceptThe end-user license agreement (EULA) must be present with a value of accept. 此外,也需要端點 URL 和 API 金鑰。Additionally, both an Endpoint URL and API Key are needed.

端點 URI{ENDPOINT_URI}Endpoint URI {ENDPOINT_URI}

[端點URI] 值可在對應認知服務資源的 [Azure 入口網站總覽] 頁面上取得。The Endpoint URI value is available on the Azure portal Overview page of the corresponding Cognitive Service resource. 流覽至 [總覽] 頁面,將滑鼠停留在端點上Copy to clipboard ,圖示就會出現。Navigate to the Overview page, hover over the Endpoint, and a Copy to clipboard icon will appear. 視需要複製並使用。Copy and use where needed.

收集端點 uri 以供稍後使用

快速鍵{API_KEY}Keys {API_KEY}

此金鑰用來啟動容器,並可在對應認知服務資源的 Azure 入口網站的 [金鑰] 頁面上取得。This key is used to start the container, and is available on the Azure portal's Keys page of the corresponding Cognitive Service resource. 流覽至 [金鑰] 頁面,然後按一下Copy to clipboard 圖示。Navigate to the Keys page, and click on the Copy to clipboard icon.

取得兩個金鑰的其中一個供稍後使用

重要

這些訂用帳戶金鑰可用來存取您的認知服務 API。These subscription keys are used to access your Cognitive Service API. 請勿共用您的金鑰。Do not share your keys. 以安全的方式儲存它們,例如使用 Azure Key Vault。Store them securely, for example, using Azure Key Vault. 我們也建議您定期重新產生這些金鑰。We also recommend regenerating these keys regularly. 進行 API 呼叫時,只需要一個金鑰。Only one key is necessary to make an API call. 重新產生第一個金鑰時,您可以使用第二個金鑰繼續存取服務。When regenerating the first key, you can use the second key for continued access to the service.

主機電腦The host computer

主機是可執行 Docker 容器的 x64 型電腦。The host is a x64-based computer that runs the Docker container. 它可以是您內部部署的電腦,或是在 Azure 中裝載服務的 Docker,例如:It can be a computer on your premises or a Docker hosting service in Azure, such as:

Advanced Vector Extension 支援Advanced Vector Extension support

主機是執行 Docker 容器的電腦。The host is the computer that runs the docker container. 主機必須支援先進向量延伸」(AVX2)。The host must support Advanced Vector Extensions (AVX2). 您可以使用下列命令來檢查 Linux 主機上的 AVX2 支援:You can check for AVX2 support on Linux hosts with the following command:

grep -q avx2 /proc/cpuinfo && echo AVX2 supported || echo No AVX2 support detected

警告

必須要有主機電腦,才能支援 AVX2。The host computer is required to support AVX2. 如果沒有 AVX2 支援,容器將無法正確運作。The container will not function correctly without AVX2 support.

容器的需求和建議Container requirements and recommendations

下表說明每個語音容器的資源的最低和建議配置。The following table describes the minimum and recommended allocation of resources for each Speech container.

容器Container 最小值Minimum 建議Recommended
語音轉文字Speech-to-text 2核心,2 GB 記憶體2 core, 2-GB memory 4核心,4 GB 記憶體4 core, 4-GB memory
  • 每個核心必須至少 2.6 GHz 或更快。Each core must be at least 2.6 gigahertz (GHz) or faster.

核心和記憶體會對應至 --cpus--memory 設定,用來作為 docker run 命令的一部分。Core and memory correspond to the --cpus and --memory settings, which are used as part of the docker run command.

注意

最低和建議是根據 Docker 限制,而是主機電腦資源。The minimum and recommended are based off of Docker limits, not the host machine resources. 例如,適用于大型語言模型的語音轉換文字容器記憶體對應部分,建議您將整個檔案納入記憶體中,這是額外的 4-6 GB。For example, speech-to-text containers memory map portions of a large language model, and it is recommended that the entire file fits in memory, which is an additional 4-6 GB. 此外,第一次執行任一容器可能需要較長的時間,因為模型會分頁到記憶體中。Also, the first run of either container may take longer, since models are being paged into memory.

使用 docker pull 取得容器映像Get the container image with docker pull

適用于語音的容器映射可在下列 Container Registry 中使用。Container images for Speech are available in the following Container Registry.

容器Container RepositoryRepository
語音轉文字Speech-to-text containerpreview.azurecr.io/microsoft/cognitive-services-speech-to-text:latest

提示

您可以使用 docker images (英文) 命令來列出已下載的容器映像。You can use the docker images command to list your downloaded container images. 例如,下列命令會列出每個已下載之容器映像的識別碼、存放庫和標籤,並將它格式化為表格:For example, the following command lists the ID, repository, and tag of each downloaded container image, formatted as a table:

docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"

IMAGE ID         REPOSITORY                TAG
<image-id>       <repository-path/name>    <tag-name>

適用于語音容器的 Docker pullDocker pull for the Speech containers

適用于語音轉換文字容器的 Docker pullDocker pull for the Speech-to-text container

使用docker pull命令從容器預覽登錄下載容器映射。Use the docker pull command to download a container image from Container Preview registry.

docker pull containerpreview.azurecr.io/microsoft/cognitive-services-speech-to-text:latest

重要

latest標記會提取 en-US 地區設定。The latest tag pulls the en-US locale. 如需其他地區設定,請參閱語音轉換文字地區設定。For additional locales see Speech-to-text locales.

語音轉換文字地區設定Speech-to-text locales

除了以外的所有標記 latest 都採用下列格式,而且會區分大小寫:All tags, except for latest are in the following format and are case-sensitive:

<major>.<minor>.<patch>-<platform>-<locale>-<prerelease>

下列標記是格式的範例:The following tag is an example of the format:

2.2.0-amd64-en-us-preview

如需語音轉換文字容器的所有支援地區設定,請參閱語音轉換文字影像標記For all of the supported locales of the speech-to-text container, please see Speech-to-text image tags.

如何使用容器How to use the container

容器位於主機電腦上時,請透過下列程序來使用容器。Once the container is on the host computer, use the following process to work with the container.

  1. 使用所需的計費設定執行容器Run the container, with the required billing settings. docker run 命令有相關範例可供參考。More examples of the docker run command are available.
  2. 查詢容器的預測端點Query the container's prediction endpoint.

透過 docker run 執行容器Run the container with docker run

docker run 命令執行容器。Use the docker run command to run the container. 如需如何取得和值的詳細資訊,請參閱收集必要的參數 {Endpoint_URI} {API_Key}Refer to gathering required parameters for details on how to get the {Endpoint_URI} and {API_Key} values. examples docker run 也可以使用命令的其他範例。Additional examples of the docker run command are also available.

若要執行語音轉換文字容器,請執行下列 docker run 命令。To run the Speech-to-text container, execute the following docker run command.

docker run --rm -it -p 5000:5000 --memory 4g --cpus 4 \
containerpreview.azurecr.io/microsoft/cognitive-services-speech-to-text \
Eula=accept \
Billing={ENDPOINT_URI} \
ApiKey={API_KEY}

此命令:This command:

  • 從容器映射執行語音轉換文字容器。Runs a Speech-to-text container from the container image.
  • 配置4個 CPU 核心和 4 gb 的記憶體。Allocates 4 CPU cores and 4 gigabytes (GB) of memory.
  • 公開 TCP 埠5000,並為容器配置虛擬 TTY。Exposes TCP port 5000 and allocates a pseudo-TTY for the container.
  • 在容器結束之後自動將其移除。Automatically removes the container after it exits. 容器映像仍可在主機電腦上使用。The container image is still available on the host computer.

在語音轉換文字輸出上分析情感Analyze sentiment on the speech-to-text output

從語音轉換文字容器的 v 2.2.0 開始,您可以在輸出上呼叫情感分析 V3 APIStarting in v2.2.0 of the speech-to-text container, you can call the sentiment analysis v3 API on the output. 若要呼叫情感分析,您將需要文字分析 API 資源端點。To call sentiment analysis, you will need a Text Analytics API resource endpoint. 例如:For example:

  • https://westus2.api.cognitive.microsoft.com/text/analytics/v3.0-preview.1/sentiment
  • https://localhost:5000/text/analytics/v3.0-preview.1/sentiment

如果您要存取雲端中的文字分析端點,您將需要金鑰。If you're accessing a Text analytics endpoint in the cloud, you will need a key. 如果您是在本機執行文字分析,可能就不需要提供這種方式。If you're running Text Analytics locally, you may not need to provide this.

金鑰和端點會當做引數傳遞至語音容器,如下列範例所示。The key and endpoint are passed to the Speech container as arguments, as in the following example.

docker run -it --rm -p 5000:5000 \
containerpreview.azurecr.io/microsoft/cognitive-services-speech-to-text:latest \
Eula=accept \
Billing={ENDPOINT_URI} \
ApiKey={API_KEY} \
CloudAI:SentimentAnalysisSettings:TextAnalyticsHost={TEXT_ANALYTICS_HOST} \
CloudAI:SentimentAnalysisSettings:SentimentAnalysisApiKey={SENTIMENT_APIKEY}

此命令:This command:

  • 執行與上述命令相同的步驟。Performs the same steps as the command above.
  • 儲存文字分析 API 端點和金鑰,以用於傳送情感分析要求。Stores a Text Analytics API endpoint and key, for sending sentiment analysis requests.

重要

必須指定 EulaBillingApiKey 選項以執行容器,否則容器將不會啟動。The Eula, Billing, and ApiKey options must be specified to run the container; otherwise, the container won't start. 如需詳細資訊,請參閱帳單For more information, see Billing.

查詢容器的預測端點Query the container's prediction endpoint

注意

如果您正在執行多個容器,請使用唯一的埠號碼。Use a unique port number if you're running multiple containers.

容器Containers SDK 主機 URLSDK Host URL 通訊協定Protocol
語音轉換文字和自訂語音轉換文字Speech-to-text and Custom Speech-to-text ws://localhost:5000 WSWS
文字轉換語音和自訂文字轉換語音Text-to-speech and Custom Text-to-speech http://localhost:5000 HTTPHTTP

如需有關使用 WSS 和 HTTPS 通訊協定的詳細資訊,請參閱容器安全性For more information on using WSS and HTTPS protocols, see container security.

語音轉換文字或自訂語音轉換文字Speech-to-text or Custom Speech-to-text

容器提供以 websocket 為基礎的查詢端點 Api,可透過語音 SDK存取。The container provides websocket-based query endpoint APIs, that are accessed through the Speech SDK. 根據預設,語音 SDK 會使用線上語音服務。By default, the Speech SDK uses online speech services. 若要使用容器,您必須變更初始化方法。To use the container, you need to change the initialization method.

提示

搭配使用語音 SDK 與容器時,您不需要提供 Azure 語音資源訂用帳戶金鑰或驗證持有人權杖When using the Speech SDK with containers, you do not need to provide the Azure Speech resource subscription key or an authentication bearer token.

請參閱以下範例。See the examples below.

從使用此 Azure 雲端初始化呼叫變更:Change from using this Azure-cloud initialization call:

var config = SpeechConfig.FromSubscription("YourSubscriptionKey", "YourServiceRegion");

若要使用容器主機進行此呼叫:to this call using the container host:

var config = SpeechConfig.FromHost(
    new Uri("ws://localhost:5000"));

分析情感Analyze sentiment

如果您將文字分析 API 認證提供給容器,您可以使用語音 SDK 來傳送具有情感分析的語音辨識要求。If you provided your Text Analytics API credentials to the container, you can use the Speech SDK to send speech recognition requests with sentiment analysis. 您可以將 API 回應設定為使用簡單詳細格式。You can configure the API responses to use either a simple or detailed format.

若要將語音用戶端設定為使用簡單的格式,請新增 "Sentiment" 做為的值 Simple.ExtensionsTo configure the Speech client to use a simple format, add "Sentiment" as a value for Simple.Extensions. 如果您想要選擇特定的文字分析模型版本,請 'latest' 將屬性設定中的取代為 speechcontext-phraseDetection.sentimentAnalysis.modelversionIf you want to choose a specific Text Analytics model version, replace 'latest' in the speechcontext-phraseDetection.sentimentAnalysis.modelversion property configuration.

speech_config.set_service_property(
    name='speechcontext-PhraseOutput.Simple.Extensions',
    value='["Sentiment"]',
    channel=speechsdk.ServicePropertyChannel.UriQueryParameter
)
speech_config.set_service_property(
    name='speechcontext-phraseDetection.sentimentAnalysis.modelversion',
    value='latest',
    channel=speechsdk.ServicePropertyChannel.UriQueryParameter
)

Simple.Extensions會傳迴響應的根層中的情感結果。Simple.Extensions will return the sentiment result in root layer of the response.

{
   "DisplayText":"What's the weather like?",
   "Duration":13000000,
   "Id":"6098574b79434bd4849fee7e0a50f22e",
   "Offset":4700000,
   "RecognitionStatus":"Success",
   "Sentiment":{
      "Negative":0.03,
      "Neutral":0.79,
      "Positive":0.18
   }
}

如果您想要完全停用情感分析,請將 false 值新增至 sentimentanalysis.enabledIf you want to completely disable sentiment analysis, add a false value to sentimentanalysis.enabled.

speech_config.set_service_property(
    name='speechcontext-phraseDetection.sentimentanalysis.enabled',
    value='false',
    channel=speechsdk.ServicePropertyChannel.UriQueryParameter
)

文字轉換語音或自訂文字轉換語音Text-to-speech or Custom Text-to-speech

容器提供以REST 為基礎的端點 apiThe container provides REST-based endpoint APIs. 有許多適用于平臺、架構和語言變化的範例原始程式碼專案There are many sample source code projects for platform, framework, and language variations available.

使用標準的文字轉換語音容器,您應該依賴所下載影像標籤的地區設定和語音。With the Standard Text-to-speech container, you should rely on the locale and voice of the image tag you downloaded. 例如,如果您下載latest標記,則預設地區設定為en-USJessaRUS語音。For example, if you downloaded the latest tag the default locale is en-US and the JessaRUS voice. 接著{VOICE_NAME} ,引數會en-US-JessaRUS是。The {VOICE_NAME} argument would then be en-US-JessaRUS. 請參閱以下的範例 SSML:See the example SSML below:

<speak version="1.0" xml:lang="en-US">
    <voice name="en-US-JessaRUS">
        This text will get converted into synthesized speech.
    </voice>
</speak>

不過,針對自訂文字轉換語音,您必須從自訂語音入口網站取得語音/型號However, for Custom Text-to-speech you'll need to obtain the Voice / model from the custom voice portal. 自訂模型名稱與語音名稱同義。The custom model name is synonymous with the voice name. 流覽至 [定型] 頁面,並複製要當做{VOICE_NAME}引數使用的語音/模型Navigate to the Training page, and copy the Voice / model to use as the {VOICE_NAME} argument.

自訂語音模型-語音名稱

請參閱以下的範例 SSML:See the example SSML below:

<speak version="1.0" xml:lang="en-US">
    <voice name="custom-voice-model">
        This text will get converted into synthesized speech.
    </voice>
</speak>

讓我們來建立 HTTP POST 要求,並提供一些標頭和資料裝載。Let's construct an HTTP POST request, providing a few headers and a data payload. 以您{VOICE_NAME}自己的值取代預留位置。Replace the {VOICE_NAME} placeholder with your own value.

curl -s -v -X POST http://localhost:5000/speech/synthesize/cognitiveservices/v1 \
 -H 'Accept: audio/*' \
 -H 'Content-Type: application/ssml+xml' \
 -H 'X-Microsoft-OutputFormat: riff-16khz-16bit-mono-pcm' \
 -d '<speak version="1.0" xml:lang="en-US"><voice name="{VOICE_NAME}">This is a test, only a test.</voice></speak>'

此命令:This command:

  • speech/synthesize/cognitiveservices/v1端點建立 HTTP POST 要求。Constructs an HTTP POST request for the speech/synthesize/cognitiveservices/v1 endpoint.
  • 指定的Accept標頭audio/*Specifies an Accept header of audio/*
  • 指定的Content-Type標頭application/ssml+xml,如需詳細資訊,請參閱要求主體Specifies a Content-Type header of application/ssml+xml, for more information, see request body.
  • 指定的X-Microsoft-OutputFormat標頭riff-16khz-16bit-mono-pcm,如需更多選項,請參閱音訊輸出Specifies a X-Microsoft-OutputFormat header of riff-16khz-16bit-mono-pcm, for more options see audio output.
  • 將指定的{VOICE_NAME} 語音合成標記語言(SSML)要求傳送至端點。Sends the Speech Synthesis Markup Language (SSML) request given the {VOICE_NAME} to the endpoint.

在相同主機上執行多個容器Run multiple containers on the same host

如果您打算使用公開的連接埠執行多個容器,請務必使用不同的公開連接埠來執行每個容器。If you intend to run multiple containers with exposed ports, make sure to run each container with a different exposed port. 例如,在連接埠 5000 上執行第一個容器,以及在連接埠 5001 上執行第二個容器。For example, run the first container on port 5000 and the second container on port 5001.

您可以讓此容器和不同的 Azure 認知服務容器在主機上一起執行。You can have this container and a different Azure Cognitive Services container running on the HOST together. 您也可以針對相同的認知服務容器執行多個容器。You also can have multiple containers of the same Cognitive Services container running.

驗證容器正在執行Validate that a container is running

有數種方式可驗證容器正在執行。There are several ways to validate that the container is running. 找出有問題之容器的外部 IP位址和公開端口,然後開啟您最愛的網頁瀏覽器。Locate the External IP address and exposed port of the container in question, and open your favorite web browser. 使用下列各種要求 Url 來驗證容器是否正在執行。Use the various request URLs below to validate the container is running. 下面所列的範例要求 Url http://localhost:5000是,但您的特定容器可能會有所不同。The example request URLs listed below are http://localhost:5000, but your specific container may vary. 請記住,您會依賴容器的外部 IP位址和公開的埠。Keep in mind that you're to rely on your container's External IP address and exposed port.

要求 URLRequest URL 目的Purpose
http://localhost:5000/ 容器會提供首頁。The container provides a home page.
http://localhost:5000/status 使用 HTTP GET 要求,以驗證容器是否正在執行,而不會造成端點查詢。Requested with an HTTP GET, to validate that the container is running without causing an endpoint query. 此要求可用來進行 Kubernetes 活躍度和整備度探查 (英文)。This request can be used for Kubernetes liveness and readiness probes.
http://localhost:5000/swagger 容器會為端點提供一組完整的檔,並使用 [試用] 功能。The container provides a full set of documentation for the endpoints and a Try it out feature. 使用此功能,您可以將自己的設定輸入至以 Web 為基礎的 HTML 表單並進行查詢,而無須撰寫任何程式碼。With this feature, you can enter your settings into a web-based HTML form and make the query without having to write any code. 當查詢傳回時,會提供範例 CURL 命令來示範所需的 HTTP 標頭和本文格式。After the query returns, an example CURL command is provided to demonstrate the HTTP headers and body format that's required.

容器的首頁

停止容器Stop the container

若要關閉容器,請在執行容器的命令列環境中,選取Ctrl + CTo shut down the container, in the command-line environment where the container is running, select Ctrl+C.

疑難排解Troubleshooting

啟動或執行容器時,您可能會遇到問題。When starting or running the container, you may experience issues. 使用輸出裝載並啟用記錄。Use an output mount and enable logging. 這麼做可讓容器產生記錄檔,這在針對問題進行疑難排解時很有説明。Doing so will allow the container to generate log files that are helpful when troubleshooting issues.

提示

如需更多疑難排解資訊和指引,請參閱認知服務容器的常見問題(FAQ)For more troubleshooting information and guidance, see Cognitive Services containers frequently asked questions (FAQ).

計費Billing

語音容器會使用您 Azure 帳戶上的語音資源,將帳單資訊傳送至 azure。The Speech containers send billing information to Azure, using a Speech resource on your Azure account.

對容器的查詢會以用於的ApiKeyAzure 資源定價層計費。Queries to the container are billed at the pricing tier of the Azure resource that's used for the ApiKey.

Azure 認知服務容器未連線至計量/計費端點,因此無法執行授權。Azure Cognitive Services containers aren't licensed to run without being connected to the metering / billing endpoint. 您必須讓容器隨時都能與計量端點進行帳單資訊的通訊。You must enable the containers to communicate billing information with the billing endpoint at all times. 認知服務容器不會將客戶資料 (例如正在分析的影像或文字) 傳送至 Microsoft。Cognitive Services containers don't send customer data, such as the image or text that's being analyzed, to Microsoft.

連線到 AzureConnect to Azure

容器需要計費引數值才能執行。The container needs the billing argument values to run. 這些值讓容器能夠連線到計費端點。These values allow the container to connect to the billing endpoint. 容器會每隔 10 到 15 分鐘回報使用量。The container reports usage about every 10 to 15 minutes. 如果容器未在允許的時間範圍內連線到 Azure,容器會繼續執行,但在還原計費端點之前不會提供查詢。If the container doesn't connect to Azure within the allowed time window, the container continues to run but doesn't serve queries until the billing endpoint is restored. 以 10 到 15 分鐘的相同時間間隔嘗試連線 10 次。The connection is attempted 10 times at the same time interval of 10 to 15 minutes. 如果在嘗試10次後無法連接到計費端點,容器就會停止服務要求。If it can't connect to the billing endpoint within the 10 tries, the container stops serving requests.

計費引數Billing arguments

docker run 下列三個選項都提供有效的值時,此命令會啟動容器:The docker run command will start the container when all three of the following options are provided with valid values:

選項Option 描述Description
ApiKey 用來追蹤帳單資訊之認知服務資源的 API 金鑰。The API key of the Cognitive Services resource that's used to track billing information.
此選項的值必須設定為中Billing指定之已布建資源的 API 金鑰。The value of this option must be set to an API key for the provisioned resource that's specified in Billing.
Billing 用來追蹤帳單資訊之認知服務資源的端點。The endpoint of the Cognitive Services resource that's used to track billing information.
此選項的值必須設定為已佈建 Azure 資源的端點 URI。The value of this option must be set to the endpoint URI of a provisioned Azure resource.
Eula 表示您接受容器的授權。Indicates that you accepted the license for the container.
此選項的值必須設定為 [接受]。The value of this option must be set to accept.

如需這些選項的詳細資訊,請參閱設定容器For more information about these options, see Configure containers.

部落格文章Blog posts

開發人員範例Developer samples

開發人員範例可從我們的 GitHub 存放庫取得。Developer samples are available at our GitHub repository.

檢視網路研討會View webinar

加入網路研討會以了解:Join the webinar to learn about:

  • 如何將認知服務部署到任何使用 Docker 的機器How to deploy Cognitive Services to any machine using Docker
  • 如何將認知服務部署到 AKSHow to deploy Cognitive Services to AKS

摘要Summary

在本文中,您已瞭解下載、安裝及執行語音容器的概念和工作流程。In this article, you learned concepts and workflow for downloading, installing, and running Speech containers. 摘要說明:In summary:

  • 語音提供四個適用于 Docker 的 Linux 容器,封裝各種功能:Speech provides four Linux containers for Docker, encapsulating various capabilities:
    • 語音轉文字Speech-to-text
    • 自訂語音轉換文字Custom Speech-to-text
    • 文字轉換語音Text-to-speech
    • 自訂文字轉換語音Custom Text-to-speech
  • 容器映射是從 Azure 中的 container registry 下載。Container images are downloaded from the container registry in Azure.
  • 容器映像是在 Docker 中執行。Container images run in Docker.
  • 不論是使用 REST API (僅限文字轉換語音)或是 SDK (語音轉換文字或文字轉換語音),您都要指定容器的主機 URI。Whether using the REST API (Text-to-speech only) or the SDK (Speech-to-text or Text-to-speech) you specify the host URI of the container.
  • 當具現化容器時,您必須提供帳單資訊。You're required to provide billing information when instantiating a container.

重要

認知服務容器在未連線至 Azure 以進行計量的情況下,將無法被授權以執行。Cognitive Services containers are not licensed to run without being connected to Azure for metering. 客戶必須啟用容器以持續與計量服務進行帳單資訊的通訊。Customers need to enable the containers to communicate billing information with the metering service at all times. 認知服務容器不會將客戶資料 (例如正在分析的影像或文字) 傳送至 Microsoft。Cognitive Services containers do not send customer data (e.g., the image or text that is being analyzed) to Microsoft.

後續步驟Next steps