Curl 云文本到语音API--语法错误
我的目标是创建一个文本到语音的应用程序。我在用电脑。我遵循了前6个步骤。我被困在教程的“从文本合成音频”部分。我在运行从教程复制的代码并将其粘贴到控制台时出错 复制的代码Curl 云文本到语音API--语法错误,curl,command-line,google-cloud-platform,google-cloud-functions,text-to-speech,Curl,Command Line,Google Cloud Platform,Google Cloud Functions,Text To Speech,我的目标是创建一个文本到语音的应用程序。我在用电脑。我遵循了前6个步骤。我被困在教程的“从文本合成音频”部分。我在运行从教程复制的代码并将其粘贴到控制台时出错 复制的代码 curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" --data "{ 'input':{ '
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-output.txt
这是在我的控制台上运行代码的输出。
C:\Users\user\AppData\Local\Google\Cloud SDK>curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) -H "Content-Type: application/json; charset=utf-8" --data "{
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
curl: (6) Could not resolve host: print-access-token)
C:\Users\user\AppData\Local\Google\Cloud SDK> 'input':{
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> '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.'
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> },
'}' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\user\AppData\Local\Google\Cloud SDK> 'voice':{
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> 'languageCode':'en-gb',
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> 'name':'en-GB-Standard-A',
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> 'ssmlGender':'FEMALE'
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> },
'}' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\user\AppData\Local\Google\Cloud SDK> 'audioConfig':{
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> 'audioEncoding':'MP3'
The filename, directory name, or volume label syntax is incorrect.
C:\Users\user\AppData\Local\Google\Cloud SDK> }
'}' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\user\AppData\Local\Google\Cloud SDK>}" "https://texttospeech.googleapis.com/v1beta1/text:synthesize" > synthesize-output.txt
'}" "https:' is not recognized as an internal or external command,
operable program or batch file.
其他信息
我最熟悉Python。我会把我的技能描述为初学者。我正在运行10号窗口 该示例似乎是为unix友好系统编写的。这些系统使用“\”来分解多行命令。如果我没记错的话,Windows使用插入符号“^”来做完全相同的事情。我会尝试用^替换该示例中的所有\并查看它是否有效。您的主要问题与以下消息有关:“curl:(6)无法解析主机:打印访问令牌)”,这是因为Windows无法识别$variable符号,因此,有两种方法可以继续: 第一种方法:
C:\Users\user\AppData\Local\Google\Cloud SDK>gcloud config list
[core]
account = text-to-speechaccount@sage-instrument-201620.iam.gserviceaccount.com
disable_usage_reporting = False
project = sage-instrument-201620
Your active configuration is: [default]