FunASR-powered video transcription, subtitle generation, and LLM-assisted clipping tool with a local Gradio UI.
Python ai-toolsai-video-editingasrauto-subtitleschinesecontent-creationfunasrfunclipgradiollmparaformerspeech-recognitionspeech-to-textsubtitles-generatortranscriptionvideo-editingvideo-processingvideo-subtitlesvideo-transcriptionwhisper-alternative
fix: keep optional ImageMagick demo import-safe
zhifu gao900e9a2a3eb1
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 8d67fa3..ff9ab50 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -34,4 +34,4 @@ jobs:python -m pip check- name: Test runtime, installation, and CLI help- run: python -m pytest -q tests/test_gradio_runtime_compat.py tests/test_installation_docs.py tests/test_cli_stage_help.py+ run: python -m pytest -q tests/test_gradio_runtime_compat.py tests/test_installation_docs.py tests/test_cli_stage_help.py tests/test_demo_import.pydiff --git a/funclip/test/imagemagick_test.py b/funclip/test/imagemagick_test.pyindex 258fa56..a5ce990 100644--- a/funclip/test/imagemagick_test.py+++ b/funclip/test/imagemagick_test.py@@ -1,18 +1,21 @@-from moviepy.editor import *-from moviepy.video.tools.subtitles import SubtitlesClip, TextClip-from moviepy.editor import VideoFileClip, concatenate_videoclips-from moviepy.video.compositing import CompositeVideoClip+"""Optional media demo; importing this module must not render a video."""-generator = lambda txt: TextClip(txt, font='./font/STHeitiMedium.ttc', fontsize=48, color='white')-subs = [((0, 2), 'sub1中文字幕'),- ((2, 4), 'subs2'),- ((4, 6), 'subs3'),- ((6, 8), 'subs4')]+if __name__ == "__main__":+ from moviepy.editor import *+ from moviepy.video.tools.subtitles import SubtitlesClip, TextClip+ from moviepy.editor import VideoFileClip, concatenate_videoclips+ from moviepy.video.compositing import CompositeVideoClip-subtitles = SubtitlesClip(subs, generator)+ generator = lambda txt: TextClip(txt, font='./font/STHeitiMedium.ttc', fontsize=48, color='white')+ subs = [((0, 2), 'sub1中文字幕'),+ ((2, 4), 'subs2'),+ ((4, 6), 'subs3'),+ ((6, 8), 'subs4')]-video = VideoFileClip("examples/2022云栖大会_片段.mp4.mp4")-video = video.subclip(0, 8)-video = CompositeVideoClip([video, subtitles.set_pos(('center','bottom'))])+ subtitles = SubtitlesClip(subs, generator)-video.write_videofile("test_output.mp4")\ No newline at end of file+ video = VideoFileClip("examples/2022云栖大会_片段.mp4.mp4")+ video = video.subclip(0, 8)+ video = CompositeVideoClip([video, subtitles.set_pos(('center','bottom'))])++ video.write_videofile("test_output.mp4")diff --git a/tests/test_demo_import.py b/tests/test_demo_import.pynew file mode 100644index 0000000..6d8d25e--- /dev/null+++ b/tests/test_demo_import.py@@ -0,0 +1,29 @@+"""Optional media demos must not run while tools import or collect them."""++from pathlib import Path+import subprocess+import sys+++def test_imagemagick_demo_import_is_side_effect_free(tmp_path):+ demo = Path(__file__).resolve().parents[1] / "funclip/test/imagemagick_test.py"+ code = """+import importlib.util+import sys++spec = importlib.util.spec_from_file_location("funclip_imagemagick_demo", sys.argv[1])+module = importlib.util.module_from_spec(spec)+spec.loader.exec_module(module)+"""+ result = subprocess.run(+ [sys.executable, "-I", "-S", "-c", code, str(demo)],+ cwd=tmp_path,+ capture_output=True,+ text=True,+ timeout=20,+ )++ assert result.returncode == 0, result.stderr+ assert result.stdout == ""+ assert result.stderr == ""+ assert list(tmp_path.iterdir()) == []