From 801a049b77bdb2d983acf9a8b2c56be866168d09 Mon Sep 17 00:00:00 2001 From: Theia Vogel Date: Sun, 18 Feb 2024 01:31:07 -0800 Subject: [PATCH] support audio/raw in stt --- 01OS/01OS/server/stt/stt.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/01OS/01OS/server/stt/stt.py b/01OS/01OS/server/stt/stt.py index 2a57c9b..588e9e4 100644 --- a/01OS/01OS/server/stt/stt.py +++ b/01OS/01OS/server/stt/stt.py @@ -25,6 +25,8 @@ def convert_mime_type_to_format(mime_type: str) -> str: return "wav" if mime_type == "audio/webm": return "webm" + if mime_type == "audio/raw": + return "dat" return mime_type @@ -43,7 +45,16 @@ def export_audio_to_wav_ffmpeg(audio: bytearray, mime_type: str) -> str: # Export to wav output_path = os.path.join(temp_dir, f"output_{datetime.now().strftime('%Y%m%d%H%M%S%f')}.wav") - ffmpeg.input(input_path).output(output_path, acodec='pcm_s16le', ac=1, ar='16k').run() + print(mime_type, input_path, output_path) + if mime_type == "audio/raw": + ffmpeg.input( + input_path, + f='s16le', + ar='16000', + ac=1, + ).output(output_path).run() + else: + ffmpeg.input(input_path).output(output_path, acodec='pcm_s16le', ac=1, ar='16k').run() try: yield output_path