将 Text to Speech Adapter 部署到 IBM Cloud Kubernetes Service 中的 Kubernetes
要在云中将 Text to Speech Adapter 部署为 IBM® Voice Gateway 环境的一部分,您可以将其部署到 IBM® Cloud Kubernetes Service 中的 Kubernetes 集群。
开始之前
- 熟悉 Voice Gateway 部署选项并部署基本环境,如 入门Voice Gateway中所述。.
-
如果您实施的是自助服务代理程序,请查找并记录以下 Watson 服务的实例的凭证:
您将无需 Text to Speech 服务实例。
- 注册 Google Cloud,并且遵循 Cloud Text-to-Speech API 快速入门文档完成以下步骤:
- 创建用于启用 Cloud Text-to-Speech API 的 Google Cloud 项目。
- 为项目创建服务帐户。
- 下载专用密钥 JSON 文件,其中包含服务帐户的凭证。
将 Text to Speech Adapter 部署到 IBM Cloud 中的 Kubernetes
以下指示信息假设您已成功将基本 Voice Gateway 环境部署到 IBM Cloud 中的 Kubernetes。有关 IBM Cloud Kubernetes Service 入门的完整设置信息,请参阅将 Voice Gateway 部署到 IBM Cloud Kubernetes Service 中的 Kubernetes。
-
在 sample.voice.gateway 存储库的本地克隆中,查找
tts-adapter/kubernetes/deploy.yamlKubernetes 部署文件,并将其复制到 Voice Gateway 部署目录。deploy.yaml文件包含 Text to Speech Adapter (tts-adapter) 容器的配置信息。每个容器的env对象包含了名称/值对的列表,每个名称/值对都与配置环境变量对应。 -
创建 Kubernetes 密钥以存储从 Google Cloud 项目下载的凭证 JSON 文件。使用
--from-file选项指定 Google 凭证文件的路径。例如:kubectl create secret generic google-credentials --from-file=/Users/user1/my-google-project-f4b426929b20.json -
通过在
deploy.json文件的volumes部分中指定 Google 凭证文件的名称来将该文件安装到部署。例如:{ ... "volumes": [{ "name": "google-credentials", "secret": { "secretName": "google-credentials", "items": [{ "key": "my-google-project-f4b426929b20.json", "path": "my-google-project-f4b426929b20.json" }] } } ] } -
在
tts-adapter容器下,在GOOGLE_APPLICATION_CREDENTIALS环境变量中指定 Google 凭证文件位置。例如:
{ "name": "GOOGLE_APPLICATION_CREDENTIALS", "value": "/tts-adapter/credentials/my-google-project-f4b426929b20.json" } -
通过在
kubectl create命令中指定部署文件来创建并部署包含 Voice Gateway 容器的 Kubernetes Pod。kubectl create -f deploy.yaml运行此命令会在 Kubernetes 集群中的单个工作程序节点上部署一个 Text To Speech Adapter Pod。
-
遵循 将 Voice Gateway 部署到 IBM Cloud Kubernetes Service 中的 Kubernetes 中的步骤,将 Voice Gateway 配置为使用 Text To Speech Adapter。打开
deploy.json文件并将 Watson Text To Speech 环境变量配置为使用 Text To Speech Adapter:{ "name": "WATSON_TTS_URL", "value": "http://tts.adapter:4500" }
重新部署 Voice Gateway 部署以使更改生效。
后续操作
您可以进一步配置 Voice Gateway 或 Text To Speech 部署,方法是分别编辑 deploy.json 和 deploy.yaml 文件以添加或更改配置变量,然后重新部署 Pod。