[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

Đang mở Phù hợp với người mới
#326 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python

Hướng nghiên cứu

Bắt đầu với audio_separator/separator/common_separator.py, đặc biệt là docstring của write_audio() và lệnh ghi nhật thời lượng. Xóa lệnh gọi librosa.get_duration() cho từng stem hoặc chuyển việc tính thời lượng sang nhánh chỉ chạy một lần cho mỗi đầu vào, rồi cập nhật docstring để mô tả tùy chọn use_soundfile. Thêm hoặc cập nhật một unit test xác nhận rằng write_audio() không đọc lại tệp đầu vào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
1.5k
Fork
216
Merge trung bình
1 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nomadkaraoke/python-audio-separator

Tất cả issue của nomadkaraoke/python-audio-separator

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.