|
@@ -332,8 +332,10 @@ async def audio_processor_loop(state: BridgeState, mqtt_client: mqtt.Client, eng
|
|
|
def audio_callback(indata: np.ndarray, frames: int, time_info, status) -> None:
|
|
def audio_callback(indata: np.ndarray, frames: int, time_info, status) -> None:
|
|
|
if status:
|
|
if status:
|
|
|
print(f"[Audio] {status}")
|
|
print(f"[Audio] {status}")
|
|
|
- chunk = indata.astype(np.float32).tobytes()
|
|
|
|
|
- loop.call_soon_threadsafe(lambda: audio_queue.put_nowait(chunk) if not audio_queue.full() else None)
|
|
|
|
|
|
|
+ chunk = indata.tobytes() # raw s16le
|
|
|
|
|
+ loop.call_soon_threadsafe(
|
|
|
|
|
+ lambda: audio_queue.put_nowait(chunk) if not audio_queue.full() else None
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
device = _choose_audio_device()
|
|
device = _choose_audio_device()
|
|
|
if device is None:
|
|
if device is None:
|
|
@@ -358,7 +360,8 @@ async def audio_processor_loop(state: BridgeState, mqtt_client: mqtt.Client, eng
|
|
|
test_audio_queue = asyncio.Queue(maxsize=240)
|
|
test_audio_queue = asyncio.Queue(maxsize=240)
|
|
|
with sd.InputStream(
|
|
with sd.InputStream(
|
|
|
device=device, samplerate=SAMPLE_RATE, channels=CHANNELS,
|
|
device=device, samplerate=SAMPLE_RATE, channels=CHANNELS,
|
|
|
- dtype="float32", blocksize=BLOCKSIZE, callback=audio_callback,
|
|
|
|
|
|
|
+ dtype="int16", # s16le — matches pcm_input mode
|
|
|
|
|
+ blocksize=BLOCKSIZE, callback=audio_callback,
|
|
|
):
|
|
):
|
|
|
while True:
|
|
while True:
|
|
|
# Drain test audio injection first if available
|
|
# Drain test audio injection first if available
|
|
@@ -387,7 +390,7 @@ def main() -> None:
|
|
|
from whisperlivekit import TranscriptionEngine
|
|
from whisperlivekit import TranscriptionEngine
|
|
|
state = BridgeState()
|
|
state = BridgeState()
|
|
|
mqtt_client = build_mqtt_client()
|
|
mqtt_client = build_mqtt_client()
|
|
|
- engine = TranscriptionEngine(model_size="large-v3", lan="en", diarization=False)
|
|
|
|
|
|
|
+ engine = TranscriptionEngine(model_size="large-v3", lan="en", diarization=False, pcm_input=True)
|
|
|
|
|
|
|
|
def _run():
|
|
def _run():
|
|
|
asyncio.run(audio_processor_loop(state, mqtt_client, engine))
|
|
asyncio.run(audio_processor_loop(state, mqtt_client, engine))
|