IBM Watson 文本转语音 curl 示例不起作用

IBM Watson text-to-speech curl example not working

这是我用来测试文本转语音的命令API:

/usr/bin/curl -k -u 'USERNAME':'PASSWORD' -X POST \
  --header 'Content-Type: application/json' \
  --header 'Accept: audio/wav' \
  --data '{"text":"hellow world","voice":"en-US_AllisonVoice"}' \
  'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize' > ./public/138106.wav

上面的命令似乎没有生成所需的音频文件。我有一个 bluemix 帐户和正确的凭据。生成了一个音频文件,但它已损坏。

--data '{"text":"hellow world","voice":"en-US_AllisonVoice"}'

试试这个:

--data "{\"text\":\"hello world\", \"voice\":\"en-US_AllisonVoice\"}"

我从此处的 API 文档中获取了此语法:https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/text-to-speech/quick-curl.shtml

他们构建的 JSON 语法似乎与您的命令不同。

voice 是一个 URL 参数。正确的 curl 命令如下所示:

/usr/bin/curl -k -u 'USERNAME':'PASSWORD' -X POST \
  --header 'Content-Type: application/json' \
  --header 'Accept: audio/wav' \
  --data '{"text":"hellow world"}' \
  'https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_AllisonVoice'

披露:我是 IBM Watson 的传播者。

我没有使用 cURL 脚本建议解决了这个问题。 但是直接转到 url:https://stream.watsonplatform.net/speech-to-text/api/v1/recognize

然后删除以下两行:

  • "word_alternatives_threshold": null,
  • "keywords_threshold": null,

这些行有问题。