Commit 5999823

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-10-27 08:57:12
chore(asr): use `wav` for ASR task
1 parent 2f2b22c
Changed files (2)
src/asr/cloudflare.py
@@ -36,8 +36,7 @@ async def cloudflare_asr(
     path = Path(path).expanduser().resolve()
     if not path.is_file():
         return {"texts": "", "error": "File not found."}
-    supported_ext = [".mp3", ".opus", ".ogg", ".oga", ".wav", ".flac", ".aac"]
-    audio_path = path if path.suffix.lower() in supported_ext else await downsampe_audio(path, ext="wav", codec="pcm_s16le")
+    audio_path = path if path.suffix.lower() != ".wav" else await downsampe_audio(path, ext="wav", codec="pcm_s16le")
     audio_path = await convert_single_channel(audio_path, ext="wav", codec="pcm_s16le")
     # max allowed file size is 25MB
     if duration < ASR.CLOUDFLARE_CHUNK_SECONDS:
src/asr/groq.py
@@ -26,8 +26,7 @@ async def groq_asr(path: str | Path, model: str = "", prompt: str = "", temperat
     path = Path(path).expanduser().resolve()
     if not path.is_file():
         return {"texts": "", "error": "File not found."}
-    supported_ext = [".aac", ".flac", ".m4a", ".mp3", ".mpeg", ".mpga", ".ogg", ".opus", ".wav", ".webm"]
-    audio_path = path if path.suffix.lower() in supported_ext else await downsampe_audio(path, ext="wav", codec="pcm_s16le")
+    audio_path = path if path.suffix.lower() != ".wav" else await downsampe_audio(path, ext="wav", codec="pcm_s16le")
     audio_path = await convert_single_channel(audio_path, ext="wav", codec="pcm_s16le")
     # max allowed file size is 25MB
     if audio_path.stat().st_size < ASR.GROQ_MAX_BYTES: