您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

配置语音服务容器Configure Speech Service containers

语音容器使客户能够构建一种经过优化的语音应用程序体系结构, 以利用强大的云功能和边缘区域。Speech containers enable customers to build one speech application architecture that is optimized to take advantage of both robust cloud capabilities and edge locality. 现在我们支持的两个语音容器是语音到文本文本到语音转换。The two speech containers we support now are speech-to-text and text-to-speech.

使用docker run命令参数配置语音容器运行时环境。The Speech container runtime environment is configured using the docker run command arguments. 此容器有多个必需设置,以及一些可选设置。This container has several required settings, along with a few optional settings. 多个示例命令均可用。Several examples of the command are available. 容器专用设置是帐单设置。The container-specific settings are the billing settings.

配置设置Configuration settings

此容器具有以下配置设置:The container has the following configuration settings:

必填Required 设置Setting 用途Purpose
Yes ApiKeyApiKey 跟踪账单信息。Tracks billing information.
No ApplicationInsightsApplicationInsights 允许向容器添加 Azure Application Insights 遥测支持。Enables adding Azure Application Insights telemetry support to your container.
Yes BillingBilling 指定 Azure 上服务资源的终结点 URI。Specifies the endpoint URI of the service resource on Azure.
Yes EulaEula 表示已接受容器的许可条款。Indicates that you've accepted the license for the container.
No FluentdFluentd 将日志和(可选)指标数据写入 Fluentd 服务器。Writes log and, optionally, metric data to a Fluentd server.
No Http ProxyHttp Proxy 配置 HTTP 代理以发出出站请求。Configures an HTTP proxy for making outbound requests.
No LoggingLogging 为容器提供 ASP.NET Core 日志记录支持。Provides ASP.NET Core logging support for your container.
No MountsMounts 从主计算机读取数据并将其写入到容器,以及从容器读回数据并将其写回到主计算机。Reads and writes data from the host computer to the container and from the container back to the host computer.

重要

ApiKeyBillingEula 设置一起使用。必须为所有三个设置提供有效值,否则容器将无法启动。The ApiKey, Billing, and Eula settings are used together, and you must provide valid values for all three of them; otherwise your container won't start. 有关使用这些配置设置实例化容器的详细信息,请参阅计费For more information about using these configuration settings to instantiate a container, see Billing.

ApiKey 配置设置ApiKey configuration setting

ApiKey 设置指定用于跟踪容器账单信息的 Azure 资源键。The ApiKey setting specifies the Azure resource key used to track billing information for the container. 必须为 ApiKey 指定一个值, 并且值必须是为Billing配置设置指定的_语音_资源的有效键。You must specify a value for the ApiKey and the value must be a valid key for the Speech resource specified for the Billing configuration setting.

可以在以下位置找到此设置:This setting can be found in the following place:

  • Azure 门户:语音资源管理,下面Azure portal: Speech's Resource Management, under Keys

ApplicationInsights 设置ApplicationInsights setting

ApplicationInsights 设置允许向容器添加 Azure Application Insights 遥测支持。The ApplicationInsights setting allows you to add Azure Application Insights telemetry support to your container. Application Insights 可深入监视容器。Application Insights provides in-depth monitoring of your container. 可以轻松监视容器的可用性、性能和使用情况。You can easily monitor your container for availability, performance, and usage. 还可以快速识别和诊断容器中的错误。You can also quickly identify and diagnose errors in your container.

下表描述了 ApplicationInsights 节支持的配置设置。The following table describes the configuration settings supported under the ApplicationInsights section.

必填Required 名称Name 数据类型Data type 描述Description
No InstrumentationKey StringString 容器遥测数据要发送到的 Application Insights 实例的检测密钥。The instrumentation key of the Application Insights instance to which telemetry data for the container is sent. 有关详细信息,请参阅适用于 ASP.NET Core 的 Application InsightsFor more information, see Application Insights for ASP.NET Core.

例如:Example:
InstrumentationKey=123456789

Billing 配置设置Billing configuration setting

Billing设置指定 Azure 上用于计量容器的计费信息的_语音_资源的终结点 URI。The Billing setting specifies the endpoint URI of the Speech resource on Azure used to meter billing information for the container. 您必须为此配置设置指定一个值, 并且该值必须是 Azure 上的_语音_资源的有效终结点 URI。You must specify a value for this configuration setting, and the value must be a valid endpoint URI for a Speech resource on Azure. 容器约每 10 到 15 分钟报告一次使用情况。The container reports usage about every 10 to 15 minutes.

可以在以下位置找到此设置:This setting can be found in the following place:

  • Azure 门户:语音概述, 标记EndpointAzure portal: Speech's Overview, labeled Endpoint
必填Required 姓名Name 数据类型Data type 描述Description
Yes Billing StringString 账单终结点 URIBilling endpoint URI

例如:Example:
Billing=https://westus.api.cognitive.microsoft.com/sts/v1.0

Eula 设置Eula setting

Eula 设置表示已接受容器的许可条款。The Eula setting indicates that you've accepted the license for the container. 必须为此配置设置指定值,并且该值必须设置为 acceptYou must specify a value for this configuration setting, and the value must be set to accept.

必填Required 名称Name 数据类型Data type 描述Description
Yes Eula 字符串String 接受许可证License acceptance

例如:Example:
Eula=accept

根据管理 Azure 使用的协议授予认知服务容器许可。Cognitive Services containers are licensed under your agreement governing your use of Azure. 如果没有管理 Azure 使用的现有协议,则表示同意管理 Azure 使用的协议是 Microsoft 在线订阅协议,其中包含联机服务条款If you do not have an existing agreement governing your use of Azure, you agree that your agreement governing use of Azure is the Microsoft Online Subscription Agreement, which incorporates the Online Services Terms. 对于预览版,还应同意 Microsoft Azure 预览版补充使用条款For previews, you also agree to the Supplemental Terms of Use for Microsoft Azure Previews. 使用容器即表示同意这些条款。By using the container you agree to these terms.

Fluentd 设置Fluentd settings

Fluentd 是一个用于统一日志记录的开放源代码数据收集器。Fluentd is an open-source data collector for unified logging. Fluentd 设置管理容器到 Fluentd 服务器的连接。The Fluentd settings manage the container's connection to a Fluentd server. 容器包含一个 Fluentd 日志记录提供程序,使容器可以向 Fluentd 服务器写入日志和(可选)指标数据。The container includes a Fluentd logging provider, which allows your container to write logs and, optionally, metric data to a Fluentd server.

下表描述了 Fluentd 节支持的配置设置。The following table describes the configuration settings supported under the Fluentd section.

名称Name 数据类型Data type 描述Description
Host StringString Fluentd 服务器的 IP 地址或 DNS 主机名。The IP address or DNS host name of the Fluentd server.
Port IntegerInteger Fluentd 服务器的端口。The port of the Fluentd server.
默认值为 24224。The default value is 24224.
HeartbeatMs IntegerInteger 检测信号间隔,以毫秒为单位。The heartbeat interval, in milliseconds. 如果在此间隔过期之前未发送事件流量,则将检测信号发送到 Fluentd 服务器。If no event traffic has been sent before this interval expires, a heartbeat is sent to the Fluentd server. 默认值为 60000 毫秒(1 分钟)。The default value is 60000 milliseconds (1 minute).
SendBufferSize IntegerInteger 为发送操作分配的网络缓冲空间,以字节为单位。The network buffer space, in bytes, allocated for send operations. 默认值为 32768 字节(32 KB)。The default value is 32768 bytes (32 kilobytes).
TlsConnectionEstablishmentTimeoutMs IntegerInteger 与 Fluentd 服务器建立 SSL/TLS 连接的超时值,以毫秒为单位。The timeout, in milliseconds, to establish a SSL/TLS connection with the Fluentd server. 默认值为 10000 毫秒(10 秒)。The default value is 10000 milliseconds (10 seconds).
如果 UseTLS 设置为 false,则会忽略此值。If UseTLS is set to false, this value is ignored.
UseTLS BooleanBoolean 指示容器是否应使用 SSL/TLS 来与 Fluentd 服务器通信。Indicates whether the container should use SSL/TLS for communicating with the Fluentd server. 默认值为 false。The default value is false.

Http 代理凭据设置Http proxy credentials settings

如果需要配置 HTTP 代理以发出出站请求,请使用以下两个参数:If you need to configure an HTTP proxy for making outbound requests, use these two arguments:

名称Name 数据类型Data type 描述Description
HTTP_PROXYHTTP_PROXY stringstring 要使用的代理,例如 http://proxy:8888The proxy to use, for example, http://proxy:8888
<proxy-url>
HTTP_PROXY_CREDSHTTP_PROXY_CREDS stringstring 对代理进行身份验证所需的凭据,例如 username:password。Any credentials needed to authenticate against the proxy, for example, username:password.
<proxy-user> stringstring 代理的用户。The user for the proxy.
<proxy-password> stringstring 与代理的 <proxy-user> 关联的密码。The password associated with <proxy-user> for the proxy.
docker run --rm -it -p 5000:5000 \
--memory 2g --cpus 1 \
--mount type=bind,src=/home/azureuser/output,target=/output \
<registry-location>/<image-name> \
Eula=accept \
Billing=<endpoint> \
ApiKey=<api-key> \
HTTP_PROXY=<proxy-url> \
HTTP_PROXY_CREDS=<proxy-user>:<proxy-password> \

日志记录设置Logging settings

Logging 设置管理容器的 ASP.NET Core 日志记录支持。The Logging settings manage ASP.NET Core logging support for your container. 可对容器使用用于 ASP.NET Core 应用程序的相同配置设置和值。You can use the same configuration settings and values for your container that you use for an ASP.NET Core application.

容器支持以下日志记录提供程序:The following logging providers are supported by the container:

提供程序Provider 用途Purpose
ConsoleConsole ASP.NET Core Console 日志记录提供程序。The ASP.NET Core Console logging provider. 支持此日志记录提供程序的所有 ASP.NET Core 配置设置和默认值。All of the ASP.NET Core configuration settings and default values for this logging provider are supported.
调试Debug ASP.NET Core Debug 日志记录提供程序。The ASP.NET Core Debug logging provider. 支持此日志记录提供程序的所有 ASP.NET Core 配置设置和默认值。All of the ASP.NET Core configuration settings and default values for this logging provider are supported.
磁盘Disk JSON 日志记录提供程序。The JSON logging provider. 此日志记录提供程序将日志数据写入输出装入点。This logging provider writes log data to the output mount.

此容器命令以 JSON 格式将日志记录信息存储到输出装入点:This container command stores logging information in the JSON format to the output mount:

docker run --rm -it -p 5000:5000 \
--memory 2g --cpus 1 \
--mount type=bind,src=/home/azureuser/output,target=/output \
<registry-location>/<image-name> \
Eula=accept \
Billing=<endpoint> \
ApiKey=<api-key> \
Logging:Disk:Format=json

当容器正在运行时,此容器命令显示调试信息(前缀为 dbug):This container command shows debugging information, prefixed with dbug, while the container is running:

docker run --rm -it -p 5000:5000 \
--memory 2g --cpus 1 \
<registry-location>/<image-name> \
Eula=accept \
Billing=<endpoint> \
ApiKey=<api-key> \
Logging:Console:LogLevel:Default=Debug

Disk 日志记录Disk logging

Disk 日志记录提供程序支持以下配置设置:The Disk logging provider supports the following configuration settings:

名称Name 数据类型Data type 描述Description
Format StringString 日志文件的输出格式。The output format for log files.
注意: 此值必须设置为 json 才能启用日志记录提供程序。Note: This value must be set to json to enable the logging provider. 如果指定了此值,但未同时在实例化容器时指定输出装入点,则会发生错误。If this value is specified without also specifying an output mount while instantiating a container, an error occurs.
MaxFileSize IntegerInteger 日志文件的最大大小,以 MB 为单位。The maximum size, in megabytes (MB), of a log file. 如果当前日志文件的大小达到或超过此值,则日志记录提供程序会启动新的日志文件。When the size of the current log file meets or exceeds this value, a new log file is started by the logging provider. 如果指定 -1,则日志文件的大小仅受输出装入点的最大文件大小(如果有)的限制。If -1 is specified, the size of the log file is limited only by the maximum file size, if any, for the output mount. 默认值为 1。The default value is 1.

有关配置 ASP.NET Core 日志记录支持的详细信息,请参阅设置文件配置For more information about configuring ASP.NET Core logging support, see Settings file configuration.

装载设置Mount settings

使用绑定装载从容器读取数据并将数据写入容器。Use bind mounts to read and write data to and from the container. 可以通过在 docker run 命令中指定 --mount 选项来指定输入装载或输出装载。You can specify an input mount or output mount by specifying the --mount option in the docker run command.

语音容器不使用输入或输出装入来存储定型或服务数据。The Speech containers don't use input or output mounts to store training or service data.

主机确切语法的安装位置因主机操作系统不同而异。The exact syntax of the host mount location varies depending on the host operating system. 此外,由于 docker 服务帐户使用的权限与主机安装位置权限之间的冲突,可能无法访问主计算机的装载位置。Additionally, the host computer's mount location may not be accessible due to a conflict between permissions used by the docker service account and the host mount location permissions.

可选Optional 姓名Name 数据类型Data type 描述Description
不允许Not allowed Input StringString 语音容器不使用此功能。Speech containers do not use this.
可选Optional Output StringString 输出装入点的目标。The target of the output mount. 默认值为 /outputThe default value is /output. 这是日志的位置。This is the location of the logs. 这包括容器日志。This includes container logs.

例如:Example:
--mount type=bind,src=c:\output,target=/output

Docker 运行命令示例Example docker run commands

以下示例使用的配置设置说明如何编写和使用 docker run 命令。The following examples use the configuration settings to illustrate how to write and use docker run commands. 运行后,容器将继续运行,直到停止它。Once running, the container continues to run until you stop it.

  • 行继续符:以下各部分中的 Docker 命令使用反斜杠 \ 作为行继续符。Line-continuation character: The Docker commands in the following sections use the back slash, \, as a line continuation character. 根据主机操作系统的要求替换或删除字符。Replace or remove this based on your host operating system's requirements.
  • 参数顺序:除非很熟悉 Docker 容器,否则不要更改参数顺序。Argument order: Do not change the order of the arguments unless you are very familiar with Docker containers.

将 {argument_name} 替换为为你自己的值:Replace {argument_name} with your own values:

占位符Placeholder ReplTest1Value 格式或示例Format or example
{API_KEY}{API_KEY} Speech AzureSpeech密钥页上的资源的终结点键。The endpoint key of the Speech resource on the Azure Speech Keys page. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{ENDPOINT_URI}{ENDPOINT_URI} Azure Speech“概览”页面上提供了账单终结点值。The billing endpoint value is available on the Azure Speech Overview page. 有关显式示例,请参阅收集所需的参数See gathering required parameters for explicit examples.

备注

2019 年 7 月 1 日之后创建的新资源将使用自定义子域名。New resources created after July 1, 2019, will use custom subdomain names. 有关详细信息和区域终结点的完整列表,请参阅认知服务的自定义子域名For more information and a complete list of regional endpoints, see Custom subdomain names for Cognitive Services.

重要

必须指定 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. ApiKey 值是 "Azure 语音资源密钥" 页中的密钥The ApiKey value is the Key from the Azure Speech Resource keys page.

语音容器 Docker 示例Speech container Docker examples

以下 Docker 示例适用于语音容器。The following Docker examples are for the Speech container.

语音到文本的基本示例Basic example for speech to text

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

文本到语音转换的基本示例Basic example for text to speech

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

将语音转换为文本的示例Logging example for speech to text

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

文本到语音的日志记录示例Logging example for text to speech

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

后续步骤Next steps