[Bug] Non-16 kHz audio is resampled on the channel axis and exported with a stale sample rate
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 funclip/videoclipper.py 中的 VideoClipper.recog 开始,跟踪规范化音频进入 clip 的流程。使用提供的合成单声道/立体声复现,分别在 8、16、44.1 和 48 kHz 下运行,然后为样本数、返回的采样率、clip 时长和输入不可变性添加或更新回归测试覆盖。完成标准是所有情况都向 ASR 提供 16,000 个单声道样本,并以 16 kHz 导出所请求的时长。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 6.4k
- 派生
- 758
- 平均合并
- 1 天 21 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelscope/FunClip 的其他 Issue
-
[Bug] Concatenated audio clips reset each SRT segment to time zero可能已有人在做 @burakeyler 于 30 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 78/100
modelscope/FunClip#216 ·
维护者通常 1 天内回复
-
[Bug] SenseVoice Chinese text clipping misses multi-character queries and uses incorrect timestamp indices可能已有人在做 @Minh3132 于 30 天前认领。 未关闭bug
难度 3/5 1-2 天 新手友好度 66/100
modelscope/FunClip#215 · 3 条评论 ·
维护者通常 1 天内回复
-
为什么总显示各种库未安装呢未关闭needs feedback question
难度 3/5 1-2 天 新手友好度 35/100
modelscope/FunClip#147 · 4 条评论 ·
维护者通常 1 天内回复
-
多人区分说话报错可能重新可做 @modelpath-dev 于 36 天前认领,目前没有进行中的 PR。 未关闭bug needs feedback
难度 3/5 1-2 天 新手友好度 42/100
modelscope/FunClip#139 · 6 条评论 ·
维护者通常 1 天内回复
-
字幕颜色改不了可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭bug needs feedback
难度 3/5 1-2 天 新手友好度 52/100
modelscope/FunClip#135 · 5 条评论 ·
维护者通常 1 天内回复
查看 modelscope/FunClip 的全部 Issue
相似的 Issue
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunk可能已有人在做 @rodricksz4h5 今天认领。 未关闭area/streaming comp/gateway P2 type/security
难度 2/5 1-3 小时 新手友好度 78/100
NousResearch/hermes-agent#138245 ·
维护者通常 1 天内回复
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS step可能已有人在做 @github-actions 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
correction metadata
难度 2/5 1 小时以内 新手友好度 68/100
acl-org/acl-anthology#10378 · 1 条评论 ·
维护者通常 1 天内回复
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom name可能已有人在做 @12YYCCYY16 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
prowler-cloud/prowler#13033 ·
维护者通常 1 天内回复
-
enhancement
难度 1/5 1-3 小时 新手友好度 88/100
graygarbage/HermesKey#23 ·