[Bug]: write_audio() docstring says soundfile is used for files over 1 hour, but that switch was removed; it also re-reads the input file for every stem

未关闭 适合新手
#326 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

从 audio_separator/separator/common_separator.py 开始,重点关注 write_audio() 的 docstring 和记录时长的调用。删除对每个 stem 调用的 librosa.get_duration(),或者将时长计算移到每个输入仅执行一次的路径中,并更新 docstring 以说明 use_soundfile 选项。添加或更新单元测试,验证 write_audio() 不会重新读取输入文件。

由索引模型根据 Issue 内容生成。

描述

bug
Describe the bug

CommonSeparator.write_audio() no longer does what its docstring says, and it still does work that only the removed behavior needed.

1. The docstring describes behavior that no longer exists

common_separator.py#L318-L336 says:

Soundfile is used for very large files (longer than 1 hour), as pydub has memory issues with large files

The automatic switch was replaced by the use_soundfile option in #125 (if duration_hours >= 1: became if self.use_soundfile:). Since then, files longer than one hour are written with pydub unless --use_soundfile is passed, so the docstring is misleading for users who hit the pydub memory issue it mentions.

2. The input file is re-read for every stem, only to log its duration

Line 326 still calls:

duration_seconds = librosa.get_duration(path=self.audio_file_path)

write_audio() runs once per stem (via final_process()), so a 4-stem model opens the input file 4 times. The result is now only used in a log message; nothing depends on it since the switch was removed.

Suggested fix

  • Update the docstring to describe the current behavior (pydub by default, soundfile when use_soundfile is set, recommended for very long files).
  • Remove the per-stem librosa.get_duration() call, or compute the duration once per input instead of once per stem.
  • Add a unit test that write_audio() does not read the input file.

I'd be happy to open a PR for this.

Have you searched for existing issues? 🔎
  • I have searched and found no existing issues.
Screenshots or Videos

No response

Logs

System Info
Operating System: Windows 10
Python version: 3.13.3
audio-separator: main (4dd3477)
Additional Information

No response

主要语言
Python
星标
1.5k
派生
216
平均合并
1 小时
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nomadkaraoke/python-audio-separator 的其他 Issue

查看 nomadkaraoke/python-audio-separator 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。