Skip to content

fix(client): pick the channel before resampling stereo files - #181

Merged
LauraGPT merged 1 commit into
QwenAudio:mainfrom
imeerkhurram:fix/client-stereo-resample
Dec 1, 2026
Merged

LauraGPT merged 1 commit into
QwenAudio:mainfrom
imeerkhurram:fix/client-stereo-resample

Conversation

@imeerkhurram

Copy link
Copy Markdown
Contributor

Summary

client_python.py and client_test.py resample before they drop to one channel. soundfile.read returns (frames, channels) and librosa.resample works 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.py already 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

  • No model behavior changes.
  • Affects Fun-ASR-Nano or Fun-ASR-MLT-Nano inference.
  • Affects streaming, vLLM, WebSocket, or client examples.
  • Affects GGUF / llama.cpp runtime assets or docs.
  • Affects Hugging Face, ModelScope, or model-card routing.

Validation

  • I ran the relevant tests or commands: the pytest command from native-transformers-examples.yml with the same pinned versions on Python 3.12, all pass.
  • I checked changed README/docs/model links.
  • I verified affected model, runtime, or example behavior with a small audio sample when applicable.

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:

assert 44100 == 16000   # client_python.py and client_test.py, 44.1 kHz
assert 8000 == 16000    # both, 8 kHz
4 failed, 2 passed

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.

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.
@LauraGPT
LauraGPT merged commit 45e9c26 into QwenAudio:main Dec 1, 2026
1 check passed
@LauraGPT

LauraGPT commented Dec 1, 2026

Copy link
Copy Markdown
Member

Thank you for the fix, @imeerkhurram. Yes, your proposed companion PR to modelscope/FunASR would be welcome. I checked the file client and the test client: both match the pre-fix files here byte for byte.

One detail for the port: the example workflow runs the streaming client tests, but doesn't explicitly install librosa, and only the test client is in its path filters. Please include the resampler in the test dependencies and cover both client paths, so those cases actually run on Python 3.10 and 3.12.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants