2
votes

Here is the command I am using to test the text-to-speech 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

The command above doesn't seem to generate the desired audio file. I have a bluemix account and the right credentials. An audio file is generated, but it's corrupt.

3
sorry the question got cut off! the above command i am using doesn't seem to generate the desire audo file. i have a bluemix account and the right credentials. a audio file is generated but its corrupt.user3818020

3 Answers

3
votes

voice is a URL parameter. The correct curl command looks like this:

/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'

Disclosure: I am an evangelist for IBM Watson.

1
votes

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

Try this:

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

I took this syntax from the API documentation found here: https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/text-to-speech/quick-curl.shtml

It seems they have built the syntax of the JSON differently than your command.

0
votes

I solved it not using the cURL scripting recommendation. But by going directly to the url: https://stream.watsonplatform.net/speech-to-text/api/v1/recognize

Then removing the following 2 lines:

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

There are issues with these lines.