Skip to content

fix(common): stop reading the mp3 output path before it is written in any_to_mp3 - #8076

Open
simpleqt wants to merge 1 commit into
1Panel-dev:v2from
simpleqt:fix/silk-mp3-conversion-reads-output-path
Open

simpleqt wants to merge 1 commit into
1Panel-dev:v2from
simpleqt:fix/silk-mp3-conversion-reads-output-path

Conversation

@simpleqt

Copy link
Copy Markdown
Contributor

Bug

any_to_mp3() fails with FileNotFoundError for every .sil / .silk / .slk audio file, so WeChat-style voice uploads cannot be converted by the speech-to-text workflow node (base_speech_to_text_node.py calls any_to_mp3 for all uploaded audio).

Root cause (apps/common/utils/common.py, any_to_mp3):

if any_path.endswith(".sil") or any_path.endswith(".silk") or any_path.endswith(".slk"):
    sil_to_wav(any_path, any_path)
    any_path = mp3_path          # <- output path
audio = AudioSegment.from_file(any_path)
...
audio.export(mp3_path, format="mp3")

sil_to_wav(any_path, any_path) decodes the silk file in place, so the decoded wav lives at any_path. The reassigned line made any_path = mp3_path before AudioSegment.from_file() runs, but mp3_path is only created by the audio.export(mp3_path, ...) call at the end of the function — pydub opens a file that does not exist yet, and every silk upload raises FileNotFoundError.

Fix

Drop the reassignment. After sil_to_wav the decoded wav is already in place at any_path, which is exactly what the non-silk branch reads; the mp3 is then exported to mp3_path as before. No caller changes (callers already pass distinct temp paths).

Verification

Standalone repro (this area of the repo has no test suite): it stubs sil_to_wav with a real stdlib-WAV writer and exercises AudioSegment.from_file routing the same way pydub does (opens the requested path before probing the format).

  • Base (v2 tip 5290738): RED: FileNotFoundError -> [Errno 2] No such file or directory: '...voice.mp3'
  • With this fix: GREEN, call sequence sil_to_wav -> from_file(voice.silk, 48044 bytes) -> export(voice.mp3)
  • ruff==0.15.12 check apps/common/utils/common.py (repo-pinned version) passes on base and with the fix.

Not run locally: the full Django/Celery app (needs PostgreSQL + Redis) and a real pysilk/ffmpeg decode; the repro stubs those two boundaries and mirrors their file-handling behavior.

The same reassignment is also present on the v3 branch.

… any_to_mp3

any_to_mp3() converts WeChat-style silk audio via sil_to_wav(any_path,
any_path), then reassigned any_path = mp3_path before decoding. That made
AudioSegment.from_file() open the output path, which does not exist until
export() runs at the end, so every .sil/.silk/.slk upload in the
speech-to-text node failed with FileNotFoundError.

Keep any_path pointing at the decoded wav written in place and export the
mp3 to mp3_path as before. The speech-to-text node (base_speech_to_text_
node.py) already passes distinct temp paths, so no caller changes.

Signed-off-by: simpleqt <2015900818@qq.com>
Copilot AI balanced review requested due to automatic review settings November 22, 2026 09:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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