fix: import numpy for eval() of xlsx columns under numpy >=2.0#560
Open
wangliangliang2008 wants to merge 1 commit into
Open
fix: import numpy for eval() of xlsx columns under numpy >=2.0#560wangliangliang2008 wants to merge 1 commit into
wangliangliang2008 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On numpy 2.0+, pandas writes numeric values to xlsx using the new repr format
(
np.float64(0.355)instead of0.355). Strings in thelinesandnew_sub_timescolumns ofoutput/audio/tts_tasks.xlsxtherefore look like: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:In the Streamlit UI this surfaces as
❌ 任务出错: name 'np' is not definedduring the dubbing step, blocking the whole pipeline at the audio-merge stage.
requirements.txtalready pinsnumpy>=2.0.2, so any fresh install will hitthis consistently.
Reproduction
NameError above
Fix
Add
import numpy as npto both files soeval()finds it in scope. Twofiles, 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.mp3output/normalized_dub.wavoutput/dub.srtRelated
When testing this I also noticed
install.pydoesn't detect whether the user'sffmpegwas built withlibass. The macOS Homebrew liteffmpegformulaships without
libass, which means thesubtitles=filter is missing entirelyand the final video merge fails with cryptic "No option name near 'output/...'"
errors. Worth a separate issue / PR to make
install.pywarn — happy to fileone if interested.