1

I'm having issues trying to adjust the prosody speaking rate in IBM Watson's TTS Service using curl. Here is the code I've tried, it does synthesize audio but just completely ignores the --header "prosody rate: +50%" ^ line I inserted which was to be expected as I'm unsure how to make that happen and just improvised that. Does anyone know how I could get it to work as intended? I want to speed it up by 50%, but I can't find anything in the docs to help me when it comes to this request format.

Thanks!

curl -X POST -u "apikey:apikey" ^
--header "Content-Type: application/json" ^
--header "Accept: audio/wav" ^
--header "prosody rate: +50%" ^
--data "{\"text\":\"Adult capybaras are one meter long.\"}" ^
--output hello_world.wav ^
"URL/v1/synthesize?voice=en-US_HenryV3Voice"
Bloggy
  • 109
  • 12

2 Answers2

0

prosody is an SSML option, so I would expect it to be used as tags around the text that you are synthesising.

--data "{\"text\":\"<prosody rate = \"fast\">Adult capybaras are one meter long.</prosody>\"}" 

chughts
  • 4,210
  • 2
  • 14
  • 27
0

Here's a working example with the POST call,

curl -X POST -u "apikey:{API_KEY}" \
--header "Accept: audio/wav" \
--header "Content-Type: application/json" \
--data '{"text": "<p><s><prosody rate=\"+50%\">This is the first sentence of the paragraph.</prosody></s><s>Here is another sentence.</s><s>Finally, this is the last sentence.</s></p>"}' \
--output result.wav \
"{URL}/v1/synthesize" -v

on a Windows command prompt(cmd),

Create a JSON file input.json with the below command

echo {"text": "<p><s><prosody rate='+50%'>This is the first sentence of the paragraph.</prosody></s><s>Here is another sentence.</s><s>Finally, this is the last sentence.</s></p>"} > input.json

and then cURL to see result.wav file

curl -X POST -u "apikey:{API_KEY}" ^
--header "Accept: audio/wav" ^
--header "Content-Type: application/json" ^
--data @input.json ^
--output result.wav ^
"{URL}/v1/synthesize" -v

For the sentence in your question, replace the JSON above with yours

{"text":"<prosody rate='fast'>Adult capybaras are one meter long.</prosody>"}

Here's some useful links I followed to create this code sample that will help you in understanding the SSML attributes. Also, check the limitations of <prosody> in the links below

Vidyasagar Machupalli
  • 2,737
  • 1
  • 19
  • 29
  • Hi, thanks for your answer and sorry for answering so late, but it's generating an audio file that's actually an error code: when I open the generated file with notepad, I get this. I can't figure out what's wrong. { "error": "Expecting value: line 1 column 1 (char 0)", "code": 400, "code_description": "Bad Request" } – Bloggy Oct 09 '20 at 14:32
  • I think it's due to the fact that I'm on Windows and ' doesn't work on Windows. How can I fix that? – Bloggy Oct 09 '20 at 14:43
  • In place of `\` in the command use `^` for new-line on Windows. Check my updated answer – Vidyasagar Machupalli Oct 09 '20 at 16:17
  • Hi, I tried that and I have the same problem, I still get the same Error 400 Bad Request. Weird, could it be due to bad escaping or maybe some formatting error? – Bloggy Oct 09 '20 at 22:42
  • Can you remove the caps the end, move everything into a single line for simplicity and try? I don’t have a Windows machine to try :( – Vidyasagar Machupalli Oct 17 '20 at 02:22
  • @Bloggy Updated my answer with the new instructions that worked for me on Windows – Vidyasagar Machupalli Oct 22 '20 at 13:57