我是这个论坛的新手。我正在尝试让 Google Cloud TTS API 正常工作,但遇到了一些问题。
页面是:https://cloud.google.com/text-to-speech/docs/quickstart-protocol https://cloud.google.com/text-to-speech/docs/quickstart-protocol
我设法浏览所有页面,直到“从文本合成音频”,正如我在下面引用的那样。我的问题是我根本不明白谷歌希望我如何运行该脚本。这看起来像是 Nix 的声明,而我使用的是 Windows。
最初我试图让 Python 示例运行起来,但从未让它运行起来。
有人尝试过这个并使它起作用吗?
引用:
从文本合成音频您可以通过向以下地址发出 HTTP POST 请求将文本转换为音频:https://texttospeech.googleapis.com/v1beta1/text:synthesize https://texttospeech.googleapis.com/v1beta1/text:synthesize端点。在 POST 命令的正文中,在语音配置部分中指定要合成的语音类型,在输入部分的文本字段中指定要合成的文本,并在audioConfig 部分中指定要创建的音频类型。
在命令行中运行以下行以合成音频
使用文本转语音 API 的文本。该命令使用gcloud 身份验证
应用程序默认打印访问令牌命令检索
请求的授权令牌。
响应被定向到输出文件synthesize-output.txt。
Curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'input':{
'text':'Android is a mobile operating system developed by Google,
based on the Linux kernel and designed primarily for
touchscreen mobile devices such as smartphones and tablets.'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Standard-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > synthesize-text.txt
你有cURL
安装了?你可以通过做检查curl -V
。
如果您还没有安装,可以按照以下步骤操作here http://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/objectstorage/restrict_rw_accs_cntainers_REST_API/files/installing_curl_command_line_tool_on_windows.html
如果您的问题是返回的响应或缺少响应,我建议使用 API 密钥而不是服务帐户密钥。
这些是获取 API 密钥所需的所有步骤
- 在中创建一个项目(或使用现有的项目)云
安慰 https://console.cloud.google.com/.
- 确保billing https://console.cloud.google.com/billing?project=_已为您的项目启用。
- 启用文本转语音 API https://console.cloud.google.com/flows/enableapi?apiid=texttospeech.googleapis.com.
- 创建一个API key https://console.cloud.google.com/apis/credentials?project=_.
然后你可以像这样使用curl命令
Curl -H "X-Goog-Api-Key: PUT_YOUR_API_KEY_HERE" \
-H "Content-Type: application/json; charset=utf-8" \
--data "{
'input':{
'text':'Android is a mobile operating system developed by Google,
based on the Linux kernel and designed primarily for
touchscreen mobile devices such as smartphones and tablets.'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Standard-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > synthesize-text.txt
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)