[Bug] Non-16 kHz audio is resampled on the channel axis and exported with a stale sample rate
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- audio-video-rtc
Línea de trabajo
Comienza en funclip/videoclipper.py, en VideoClipper.recog, y sigue el audio normalizado hasta clip. Ejecuta la reproducción sintética mono/estéreo proporcionada con 8, 16, 44.1 y 48 kHz, y añade o actualiza la cobertura de regresión para el número de muestras, la tasa devuelta, la duración del clip y la inmutabilidad de la entrada. Se considera completado cuando todos los casos proporcionan 16,000 muestras mono a ASR y exportan la duración solicitada a 16 kHz.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Non-16 kHz audio uploaded to FunClip has two normalization errors: stereo data is resampled along the channel axis before selecting the first channel, and the normalized waveform is stored with its original sample rate. This changes the waveform duration seen by ASR and the playback duration of exported audio clips.
Environment
- FunClip: current main
9e720617949e32da4c0a564d10cf5a64337fe2c2; five relevant local source files were verified against exact-main Git blobs. - FunASR: 1.4.15 installed, but no model inference was used in this reproduction.
- OS/Python: Linux x86-64, Python 3.12 environment.
- Installation: isolated venv with the unchanged FunClip requirements and matched torch/torchaudio 2.10.0+cpu.
- Gradio: 4.44.1; librosa 0.11.0; NumPy 1.26.4; soundfile 0.14.0.
- CPU processing. No browser session, GPU or original reporter environment was tested.
Audio or video input
- Synthetic one-second waveforms at 8, 16, 44.1 and 48 kHz, mono and stereo.
- Left channel: 440 Hz sine; right channel: 880 Hz sine. These are diagnostic tones, not spoken-language accuracy samples.
- ASR: a capture-only stand-in returns fixed text/timestamps; actual
VideoClipper.recog,clip, librosa and audio serialization run unmodified. No hotwords or LLM provider. - Additional UI-component check uses actual
gr.Audio().preprocess(FileData(...))on PCM16 WAVs andpostprocess()on the clip tuple. This verifies component serialization, not browser end-to-end behavior.
Steps to reproduce
Run from the repository root with the installed requirements:
import sys
import numpy as np
sys.path.insert(0, "funclip")
from videoclipper import VideoClipper
class CaptureASR:
def generate(self, data, **kwargs):
self.samples = len(data)
return [{"text": "test", "raw_text": "test",
"timestamp": [[0, 500]]}]
for rate in (16000, 48000):
t = np.arange(rate) / rate
left = 0.2 * np.sin(2 * np.pi * 440 * t)
for channels in (1, 2):
audio = left if channels == 1 else np.stack(
[left, 0.3 * np.sin(2 * np.pi * 880 * t)], axis=1)
model = CaptureASR()
clipper = VideoClipper(model)
clipper.lang = "en"
_, _, state = clipper.recog((rate, audio))
(out_rate, out), _, _ = clipper.clip(
"", 0, 0, state, timestamp_list=[[0, 8000]])
print(rate, channels, model.samples, out_rate, len(out) / out_rate)
The explicit timestamp range selects the first 8,000 samples of the internal 16 kHz clipping timeline, so the requested output duration is 0.5 seconds. The fixed transcript deliberately removes recognition variability from this audio-processing test.
Expected behavior
Every one-second input should supply 16,000 mono samples to ASR, preserving the existing first-channel selection policy. State and returned audio should identify the normalized waveform as 16 kHz. The requested half-second clip should serialize and play for 0.5 seconds. The caller's input array should remain unchanged.
Actual behavior
| Input | ASR samples | ASR duration at 16 kHz | Export rate | Half-second clip duration |
|---|---|---|---|---|
| 16 kHz mono | 16000 | 1 s | 16000 | 0.5 s |
| 16 kHz stereo | 16000 | 1 s | 16000 | 0.5 s |
| 48 kHz mono | 16000 | 1 s | 48000 | 0.166667 s |
| 48 kHz stereo | 48000 | 3 s | 48000 | 0.166667 s |
The expanded eight-case direct probe also reproduces failures at 8 and 44.1 kHz: six cases violate the duration/rate contract; both 16 kHz controls pass. Input arrays remained unchanged. Actual Gradio PCM16 upload/export gives the same four-case results above.
Logs or traceback
There is no exception in these cases. The output is structurally accepted but has the wrong sample count or rate. The real Gradio serialization probe completed with exit code 0; this is a successful reproduction of incorrect behavior, not a passing regression test.
The root is in recog's normalization order and state assignment. librosa.resample uses the last axis unless specified, while Gradio supplies stereo arrays shaped (samples, channels). The code selects data[:, 0] only after this operation and stores (sr, data) without changing sr. clip slices in a 16 kHz timeline but returns that stale rate.
Screenshots or clips
The sample-count and serialized-WAV duration measurements above are the evidence; no screenshot is needed to demonstrate the rate mismatch. Recognition quality, model timestamps, video exports and speaker diarization have not been evaluated here.
Related historical context: #18 fixed the old 16 kHz assertion and had reporter confirmation; #29 addressed integer PCM conversion. Neither is the current resampling-axis/stale-rate failure, so they have not been reopened. The separate installation and multi-speaker reports #147/#139 are not claimed to have the same cause.
This report was prepared with Codex assistance. No production fix or release has been made for this report yet.
- Lenguaje dominante
- Python
- Estrellas
- 6.3k
- Forks
- 753
- Merge medio
- 19 h 55 min
- PR fusionados (30 d)
- 8
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de modelscope/FunClip
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
modelscope/FunClip#216 ·
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
modelscope/FunClip#215 · 3 comentarios ·
-
为什么总显示各种库未安装呢 Abiertoneeds feedback question
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
modelscope/FunClip#147 · 4 comentarios ·
-
多人区分说话报错 Abiertobug needs feedback
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
modelscope/FunClip#139 · 6 comentarios ·
-
字幕颜色改不了 Abiertobug needs feedback
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
modelscope/FunClip#135 · 5 comentarios ·
Todos los issues de modelscope/FunClip
Issues similares
-
[Bug] reef-hermes tells me to resume with hermes --resume, which does not work from my shell Abiertoarea: harness bug status: needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Human-Agent-Society/reef#625 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
learningequality/kolibri#15351 · 2 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Name consistency Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
eellak/triplestore#65 · 1 comentario ·