diff --git a/speech.py b/speech.py index 0ea970e..09c320f 100755 --- a/speech.py +++ b/speech.py @@ -602,6 +602,8 @@ def build_ffmpeg_args(response_format, input_format, sample_rate): ffmpeg_args.extend(["-f", "flac", "-c:a", "flac"]) elif response_format == "wav": ffmpeg_args.extend(["-f", "wav", "-c:a", "pcm_s16le"]) + elif response_format == "webm": + ffmpeg_args.extend(["-f", "webm", "-c:a", "libopus"]) elif response_format == "pcm": # even though pcm is technically 'raw', we still use ffmpeg to adjust the speed ffmpeg_args.extend(["-f", "s16le", "-c:a", "pcm_s16le"]) @@ -749,6 +751,8 @@ async def generate_speech(request: GenerateSpeechRequest): media_type = "audio/x-flac" elif response_format == "wav": media_type = "audio/wav" + elif response_format == "webm": + media_type = "audio/webm;codecs=opus" elif response_format == "pcm": if model == 'tts-1': # piper media_type = "audio/pcm;rate=22050"