Skip to content

fix: import numpy for eval() of xlsx columns under numpy >=2.0#560

Open
wangliangliang2008 wants to merge 1 commit into
Huanshere:mainfrom
wangliangliang2008:fix/numpy2-eval-import
Open

fix: import numpy for eval() of xlsx columns under numpy >=2.0#560
wangliangliang2008 wants to merge 1 commit into
Huanshere:mainfrom
wangliangliang2008:fix/numpy2-eval-import

Conversation

@wangliangliang2008
Copy link
Copy Markdown

Problem

On numpy 2.0+, pandas writes numeric values to xlsx using the new repr format
(np.float64(0.355) instead of 0.355). Strings in the lines and
new_sub_times columns of output/audio/tts_tasks.xlsx therefore look like:

'[[np.float64(5.205), np.float64(7.965)]]'

These columns are deserialized via eval() in:

  • core/_10_gen_audio.py (lines 68, 165, 187)
  • core/_11_merge_audio.py (lines 19, 22, 32)

Neither file imports numpy, so eval() raises:

NameError: name 'np' is not defined

In the Streamlit UI this surfaces as ❌ 任务出错: name 'np' is not defined
during the dubbing step, blocking the whole pipeline at the audio-merge stage.

requirements.txt already pins numpy>=2.0.2, so any fresh install will hit
this consistently.

Reproduction

  1. Fresh install on macOS / Linux (or anywhere numpy>=2.0 is installed)
  2. Run any video through transcription → translation → TTS → dubbing
  3. At the "Audio merging" step in tab c. 配音, the task aborts with the
    NameError above

Fix

Add import numpy as np to both files so eval() finds it in scope. Two
files, two lines + an explanatory comment.

Test

Tested on macOS 26.5 + Python 3.10.20 + numpy 2.2.6, with a 4-minute YouTube
clip translated and dubbed end-to-end. Pipeline now completes through:

  • output/dub.mp3
  • output/normalized_dub.wav
  • output/dub.srt
  • final merged video

Related

When testing this I also noticed install.py doesn't detect whether the user's
ffmpeg was built with libass. The macOS Homebrew lite ffmpeg formula
ships without libass, which means the subtitles= filter is missing entirely
and the final video merge fails with cryptic "No option name near 'output/...'"
errors. Worth a separate issue / PR to make install.py warn — happy to file
one if interested.

…eval() compat

On numpy 2.0+, pandas writes numeric values to xlsx using the new repr format
(np.float64(0.355) instead of 0.355). Strings in the `lines` and `new_sub_times`
columns of output/audio/tts_tasks.xlsx therefore look like
'[[np.float64(5.205), np.float64(7.965)]]'.

These columns are deserialized via eval() in _10_gen_audio.py (lines 68, 165, 187)
and _11_merge_audio.py (lines 19, 22, 32). Neither file imports numpy, so eval()
raises:

    NameError: name 'np' is not defined

In the Streamlit UI this surfaces as `❌ 任务出错: name 'np' is not defined`
during the dubbing step, blocking the whole pipeline.

requirements.txt already pins numpy>=2.0.2 so users invariably hit this on a
fresh install.

Tested on macOS 26.5 + Python 3.10.20 + numpy 2.2.6: pipeline now completes
through to output/dub.mp3 and the final merged video.
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.

1 participant