Repository navigation
fix(client): pick the channel before resampling stereo files - #181
Conversation
soundfile returns (frames, channels) and librosa resamples the last axis, so a stereo file that was not 16 kHz was resampled across its two channels and sent at its original rate, labelled as 16 kHz.
|
Thank you for the fix, @imeerkhurram. Yes, your proposed companion PR to One detail for the port: the example workflow runs the streaming client tests, but doesn't explicitly install For a concrete cross-check, I sent one second of 48 kHz stereo with a 375 Hz left channel and a different, louder right channel to a loopback receiver. Before the fix both clients sent 48,000 samples. After it, both sent exactly the same 16,000 samples as the isolated left-channel control. No model or microphone was needed. |
Summary
client_python.pyandclient_test.pyresample before they drop to one channel.soundfile.readreturns(frames, channels)andlibrosa.resampleworks on the last axis, so for a stereo file it resamples across the two channels: one second at 48 kHz goes from(48000, 2)to(48000, 1). The first column is then sent as 16 kHz audio, so the server hears it three times too slow (44.1 kHz: 2.76 times, 8 kHz: twice too fast). Mono files and 16 kHz files are fine, which hides it.The channel is now picked first, the order
examples/transformers/transcribe.pyalready uses. Which channel is sent does not change.User impact
Anyone who streams a stereo recording that isn't 16 kHz with the file client.
Model and runtime impact
Validation
native-transformers-examples.ymlwith the same pinned versions on Python 3.12, all pass.Screenshots, logs, or transcripts
The new test runs both clients against a local websocket server with a one second stereo tone and checks how many samples arrive and their pitch. On main:
With the change: 6 passed (14 in the file).
Notes for reviewers
I didn't run a real model or server. FunASR has identical copies of both files in
examples/industrial_data_pretraining/fun_asr_nano, I can send the same change there if you want it.