Search code examples
text-to-speechibm-watsonnode-red

how to set the audio file sample rate for watson text to speech in node-red


watson text to speech accepts extra parameters such as the sampling (default is 44khz)

see https://www.ibm.com/watson/developercloud/text-to-speech/api/v1/#synthesize_audio for options such as this one

(...)
audio/l16;rate=rate 
(You can optionally specify endianness=big-endian 
or endianness=little-endian; the default is little endian.) 
(...)

but I can't see a way to set these options in node red

enter image description here


Solution

  • In the Node-red, doesn't have the option, because you need to add in your cURL.

    As you can see, you can use Accept or accept query parameter header to specify the audio format.

    enter image description here

    For example:

    curl -X POST -u "{username}":"{password}"
    --header "Content-Type: application/json"
    --header "Accept: audio/l16;endianness=big-endian"
    --data "{\"text\":\"Hello world\"}"
    --output hello_world.wav
    "https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_AllisonVoice"