Replies: 1 comment 1 reply
|
Hey! The mlx-audio streaming API expects you to yield raw PCM chunks (16kHz, mono, 16-bit) from an iterator. You can set up mic_stream like this: import sounddevice as sd
import numpy as np
def mic_stream(chunk_size=4096, sample_rate=16000):
chunks = []
def callback(indata, frames, time, status):
pcm = (indata[:, 0] * 32767).astype(np.int16)
chunks.append(pcm.tobytes())
with sd.InputStream(samplerate=sample_rate, channels=1, dtype="float32", blocksize=chunk_size, callback=callback):
while True:
if chunks:
yield chunks.pop(0)Then use your loop: state = model.init_streaming_state()
for chunk in mic_stream():
for result in model.generate_stream(chunk, state=state, sample_rate=16000):
state = result.state
for seg in result.segments:
print(f"Speaker {seg.speaker}: {seg.start:.2f}s - {seg.end:.2f}s")If mic_stream() is already in the repo, check its signature – usually it yields bytes and you just iterate. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Can someone please help me setup this to feed in real live microphone audio to diarize at that time. I am seeing an function called mic_stream(). But nothing of what it is or how to setup .
Real-time streaming (e.g. microphone):
state = model.init_streaming_state()
for chunk in mic_stream(): # your audio source
for result in model.generate_stream(chunk, state=state, sample_rate=16000):
state = result.state
for seg in result.segments:
print(f"Speaker {seg.speaker}: {seg.start:.2f}s - {seg.end:.2f}s")
Somebody please help me setup this.
All reactions