eheikes / tts

Tools to convert text to speech :books::speech_balloon:
Apache License 2.0
94 stars 19 forks source link

negative pitch values fail using gcp mode using -2.0 works fine with +2.0 #39

Closed sonodave closed 5 years ago

sonodave commented 5 years ago

The generateSpeech Options seems to generate a null value if a negative value is used for the pitch parameter. example -2.0 Works fine with a positive value +2.0

  1. What is the exact command you are running? For your security, please "X" out any AWS access keys and secrets.

tts test.txt test.mp3 --service gcp --project-file xxxx.json --language en-uS --type ssml --voice en-US-Wavenet-B --pitch -2.0

tts-cli called with arguments {"2":0,"_":["test.txt","test.mp3"],"service":"gcp","project-file":"xxxx.json","language":"en-uS","type":"ssml","voice":"en-US-Wavenet-B","pitch":true} +0ms

  1. What result are you seeing in the console? Copy & paste the exact output you get, with debugging turned on

tts-cli called with arguments {"2":0,"_":["test.txt","test.mp3"],"service":"gcp","project-file":"xxxx.json","language":"en-uS","type":"ssml","voice":"en-US-Wavenet-B","pitch":true} +0ms

generateSpeech Options: {"ffmpeg":"ffmpeg","format":"mp3","language":"en-uS","limit":5,"pitch":null,"projectFile":"xxxx.json","region":"us-east-1","type":"ssml","voice":"en-US-Wavenet-B"} +0ms

generate Error during request: 3 INVALID_ARGUMENT: Synthesizer RPC generic::invalid_argument: Invalid (or unsupported) synthesis parameters +0ms generateAll Requested all parts, with error Error: 3 INVALID_ARGUMENT: Synthesizer RPC generic::invalid_argument: Invalid (or unsupported) synthesis parameters +0ms generate Error during request: 3 INVALID_ARGUMENT: Synthesizer RPC generic::invalid_argument: Invalid (or unsupported) synthesis parameters +0ms Error: 3 INVALID_ARGUMENT: Synthesizer RPC generic::invalid_argument: Invalid (or unsupported) synthesis parameters at Object.exports.createStatusError (C:\Users\ElJefe\AppData\Roaming\npm\node_modules\tts-cli\node_modules\grpc\src\common.js:87:15) at Object.onReceiveStatus (C:\Users\ElJefe\AppData\Roaming\npm\node_modules\tts-cli\node_modules\grpc\src\client_interceptors.js:1188:28) at InterceptingListener._callNext (C:\Users\ElJefe\AppData\Roaming\npm\node_modules\tts-cli\node_modules\grpc\src\client_interceptors.js:564:42) at InterceptingListener.onReceiveStatus (C:\Users\ElJefe\AppData\Roaming\npm\node_modules\tts-cli\node_modules\grpc\src\client_interceptors.js:614:8) at callback (C:\Users\ElJefe\AppData\Roaming\npm\node_modules\tts-cli\node_modules\grpc\src\client_interceptors.js:841:24)

  1. If copyright allows, please upload your input file somewhere (e.g. pastebin) and put a link to it here.

  2. What OS are you using (Windows, OSX, Linux) and what version?

  3. What version of Node.js is being used? (Run node -v in the console to find out.)

  4. What version of ffmpeg is being used? (Run ffmpeg -version in the console to find out.)

eheikes commented 5 years ago

Oh yes, I ran into this too but forgot to mention it in the docs. The problem is in how the CLI parser interprets arguments that begin with a hyphen. The workaround is to use the alternate "equal sign" format for those arguments: tts test.txt test.mp3 --service gcp --project-file xxxx.json --language en-uS --type ssml --voice en-US-Wavenet-B --pitch=-2.0 (note the = between the pitch name and value).

I might be able to tweak the code so that the equal-sign format is not necessary. At the very least I'll add a note to the docs to point that out.

More technical explanation: The parser module follows POSIX conventions, so anything that begins with a hyphen is considered an option. So something like --pitch -2 is interpreted as 2 different options, pitch=true and 2=true (nevermind that seems nonsensical), rather than pitch=2.