Commit 909f765

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-07-04 08:36:16
perf(asr): make splitting of audio files async
1 parent 9955c39
Changed files (2)
src/asr/gemini.py
@@ -173,7 +173,8 @@ async def gemini_file_chunks(
             if chunk.shape[0] == 0:  # empty chunk
                 continue
             with tempfile.NamedTemporaryFile(suffix=".ogg", delete=False) as chunk_file:
-                sf.write(chunk_file.name, chunk, sr, format="ogg", subtype="OPUS")
+                chunk_path = chunk_file.name
+                await asyncio.to_thread(sf.write, chunk_path, chunk, sr, format="ogg", subtype="OPUS")
                 tasks.append(
                     gemini_single_file(
                         message,
src/asr/groq.py
@@ -308,7 +308,8 @@ async def groq_file_chunks(
             if chunk.shape[0] == 0:  # empty chunk
                 continue
             with tempfile.NamedTemporaryFile(suffix=".ogg", delete=False) as chunk_file:
-                sf.write(chunk_file.name, chunk, sr, format="ogg", subtype="OPUS")
+                chunk_path = chunk_file.name
+                await asyncio.to_thread(sf.write, chunk_path, chunk, sr, format="ogg", subtype="OPUS")
                 tasks.append(
                     groq_single_file(
                         chunk_file.name,