matatonic / openedai-speech

An OpenAI API compatible text to speech server using Coqui AI's xtts_v2 and/or piper tts as the backend.
GNU Affero General Public License v3.0
192 stars 32 forks source link

Better error handling of invalid parameters. #3

Closed jmtatsch closed 1 month ago

jmtatsch commented 2 months ago

Here, I had by chance the non existing voice 'alls'

server-1  |   File "/app/speech.py", line 141, in generate_speech
server-1  |     piper_model, speaker = map_voice_to_speaker(voice, 'tts-1')
server-1  |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
server-1  |   File "/app/speech.py", line 90, in map_voice_to_speaker
server-1  |     return (voice_map[model][voice]['model'], voice_map[model][voice]['speaker'])
server-1  |             ~~~~~~~~~~~~~~~~^^^^^^^
server-1  | KeyError: 'alls'
jmtatsch commented 2 months ago

It doesn't really die, this was premature...

matatonic commented 2 months ago

it should error back to the user instead of this behavior. I'll rename & reopen the bug for tracking.

Thanks for the report.

JohnSmithToYou commented 1 month ago

Yes, especially with the /v1/audio/speech endpoint. If you pass in a model other than "tts-1-hd" or "tts-1" you get:

server-1  |   File "/app/speech.py", line 193, in generate_speech
server-1  |     ffmpeg_args.extend(["-"])
matatonic commented 1 month ago

Good point, thanks for the feedback!