user3818020
user3818020

Reputation: 103

IBM Watson text-to-speech curl example not working

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.

Upvotes: 2

Views: 2829

Answers (3)

user8693888
user8693888

Reputation: 1

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.

Upvotes: 0

Abtin Forouzandeh
Abtin Forouzandeh

Reputation: 5855

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.

Upvotes: 3

Daniel McCrevan
Daniel McCrevan

Reputation: 179

--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.

Upvotes: 1

Related Questions