lpm*_*sen 2 cloud text-to-speech
我是这个论坛的新手。我试图让 Google Cloud TTS API 正常工作,但遇到了一些问题。
页面为:https : //cloud.google.com/text-to-speech/docs/quickstart-protocol
正如我在下面引用的那样,我设法浏览了所有页面,直到“从文本合成音频”。我的问题是我根本不明白谷歌希望我如何运行脚本。这似乎是一个 Nix 声明,我使用的是 Windows。
最初我试图让 Python 示例工作,但我从来没有让它工作。
有人试过这个并让它工作吗?
引文:
从文本合成音频 您可以通过向https://texttospeech.googleapis.com/v1beta1/text:synthesize端点发出 HTTP POST 请求来将文本转换为音频。在 POST 命令的正文中,在语音配置部分指定要合成的语音类型,在输入部分的文本字段中指定要合成的文本,并在 audioConfig 部分指定要创建的音频类型。
在命令行中运行以下行以使用 Text-to-Speech API 从文本合成音频。该命令使用gcloud auth application-default print-access-token命令检索请求的授权令牌。
响应被定向到输出文件,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
Run Code Online (Sandbox Code Playgroud)
你cURL安装了吗?你可以通过做检查curl -V。如果你没有安装它,你可以按照这里的步骤操作
如果您的问题是返回的响应或缺少响应,我建议使用 API 密钥而不是服务帐户密钥。
这些是获取 API 密钥所需的所有步骤
然后你可以像这样使用 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5081 次 |
| 最近记录: |