fix: wait for finalized wav header before transcription
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import os
|
||||
import sys
|
||||
import wave
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
@@ -106,3 +107,25 @@ def test_meeting_recorder_wraps_wave_sink_with_silence_generator(tmp_path, monke
|
||||
assert created["silence"].destination is created["wave"]
|
||||
assert vc.listened_sink is created["silence"]
|
||||
assert recorder.recording is True
|
||||
|
||||
|
||||
def test_wait_for_file_ready_rejects_stable_but_invalid_wav(tmp_path):
|
||||
broken = tmp_path / "meeting.wav"
|
||||
broken.write_bytes(b"not a real wav file")
|
||||
|
||||
ready = asyncio.run(bot.wait_for_file_ready(str(broken), attempts=3, delay=0.001))
|
||||
|
||||
assert ready is False
|
||||
|
||||
|
||||
def test_wait_for_file_ready_accepts_valid_wav(tmp_path):
|
||||
valid = tmp_path / "meeting.wav"
|
||||
with wave.open(str(valid), "wb") as wav_file:
|
||||
wav_file.setnchannels(1)
|
||||
wav_file.setsampwidth(2)
|
||||
wav_file.setframerate(16000)
|
||||
wav_file.writeframes(b"\x00\x00" * 160)
|
||||
|
||||
ready = asyncio.run(bot.wait_for_file_ready(str(valid), attempts=3, delay=0.001))
|
||||
|
||||
assert ready is True
|
||||
|
||||
Reference in New Issue
Block a user