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
code update
维石2313a6217afb
diff --git a/funclip/introduction.py b/funclip/introduction.pynew file mode 100644index 0000000..01d235d--- /dev/null+++ b/funclip/introduction.py@@ -0,0 +1,30 @@+top_md_1 = ("""+ 基于阿里巴巴通义实验室自研SeACo-Paraformer-长音频版的语音识别、端点检测、标点预测、时间戳功能、角色区分、热词定制化功能++ 准确识别,自由复制所需段落,或者设置说话人标识,一键裁剪、添加字幕++ * Step1: 上传视频或音频文件(或使用下方的用例体验),点击 **<font color="#f7802b">识别</font>** 按钮+ * Step2: 复制识别结果中所需的文字至右上方,或者右设置说话人标识,设置偏移与字幕配置(可选)+ * Step3: 点击 **<font color="#f7802b">裁剪</font>** 按钮或 **<font color="#f7802b">裁剪并添加字幕</font>** 按钮获得结果+ """)++top_md_2 = ("""+ 受到网络传输与服务资源的限制,用于体验的视频最好大小在40mb以下+ 过大的视频可以尝试分离音轨使用音频剪辑,或 **<font color="#1785c4">通过源代码将您的ClipVideo服务部署在本地(推荐)</font>** :+ <div align="center">+ <div style="display:flex; gap: 0.25rem;" align="center">+ FunASR_APP: <a href='https://github.com/alibaba/funasr-app'><img src='https://img.shields.io/badge/Github-Code-blue'></a>+ 🌟支持我们: <a href='https://github.com/alibaba/funasr-app/stargazers'><img src='https://img.shields.io/github/stars/alibaba/funasr-app.svg?style=social'></a>+ </div>+ </div>+ """)++top_md_3 = ("""访问FunASR项目与论文能够帮助您深入了解ParaClipper中所使用的语音处理相关模型:+ <div align="center">+ <div style="display:flex; gap: 0.25rem;" align="center">+ FunASR: <a href='https://github.com/alibaba-damo-academy/FunASR'><img src='https://img.shields.io/badge/Github-Code-blue'></a>+ FunASR Paper: <a href="https://arxiv.org/abs/2305.11013"><img src="https://img.shields.io/badge/Arxiv-2305.11013-orange"></a>+ 🌟Star FunASR: <a href='https://github.com/alibaba-damo-academy/FunASR/stargazers'><img src='https://img.shields.io/github/stars/alibaba-damo-academy/FunASR.svg?style=social'></a>+ </div>+ </div>+ """)diff --git a/funclip/launch.py b/funclip/launch.pyindex ea67d30..6daf244 100644--- a/funclip/launch.py+++ b/funclip/launch.py@@ -1,19 +1,15 @@import gradio as grfrom funasr import AutoModelfrom videoclipper import VideoClipper+from introduction import top_md_1, top_md_2, top_md_3if __name__ == "__main__":-funasr_model = AutoModel(model="iic/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",- model_revision="v2.0.4",- vad_model="damo/speech_fsmn_vad_zh-cn-16k-common-pytorch",- vad_model_revision="v2.0.4",- punc_model="damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch",- punc_model_revision="v2.0.4",- spk_model="damo/speech_campplus_sv_zh-cn_16k-common",- spk_model_revision="v2.0.2",- )+ vad_model="damo/speech_fsmn_vad_zh-cn-16k-common-pytorch",+ punc_model="damo/punc_ct-transformer_zh-cn-common-vocab272727-pytorch",+ spk_model="damo/speech_campplus_sv_zh-cn_16k-common",+ )audio_clipper = VideoClipper(funasr_model)def audio_recog(audio_input, sd_switch, hotwords):@@ -45,40 +41,8 @@ if __name__ == "__main__":(sr, res_audio), message, clip_srt = audio_clipper.clip(dest_text, start_ost, end_ost, audio_state, dest_spk=video_spk_input)return None, (sr, res_audio), message, clip_srt- top_md_1 = ("""- 基于阿里巴巴通义实验室自研SeACo-Paraformer-长音频版的语音识别、端点检测、标点预测、时间戳功能、角色区分、热词定制化功能-- 准确识别,自由复制所需段落,或者设置说话人标识,一键裁剪、添加字幕-- * Step1: 上传视频或音频文件(或使用下方的用例体验),点击 **<font color="#f7802b">识别</font>** 按钮- * Step2: 复制识别结果中所需的文字至右上方,或者右设置说话人标识,设置偏移与字幕配置(可选)- * Step3: 点击 **<font color="#f7802b">裁剪</font>** 按钮或 **<font color="#f7802b">裁剪并添加字幕</font>** 按钮获得结果- """)-- top_md_2 = ("""- 受到网络传输与服务资源的限制,用于体验的视频最好大小在40mb以下- 过大的视频可以尝试分离音轨使用音频剪辑,或 **<font color="#1785c4">通过源代码将您的ClipVideo服务部署在本地(推荐)</font>** :- <div align="center">- <div style="display:flex; gap: 0.25rem;" align="center">- FunASR_APP: <a href='https://github.com/alibaba/funasr-app'><img src='https://img.shields.io/badge/Github-Code-blue'></a>- 🌟支持我们: <a href='https://github.com/alibaba/funasr-app/stargazers'><img src='https://img.shields.io/github/stars/alibaba/funasr-app.svg?style=social'></a>- </div>- </div>- """)-- top_md_3 = ("""访问FunASR项目与论文能够帮助您深入了解ParaClipper中所使用的语音处理相关模型:- <div align="center">- <div style="display:flex; gap: 0.25rem;" align="center">- FunASR: <a href='https://github.com/alibaba-damo-academy/FunASR'><img src='https://img.shields.io/badge/Github-Code-blue'></a>- FunASR Paper: <a href="https://arxiv.org/abs/2305.11013"><img src="https://img.shields.io/badge/Arxiv-2305.11013-orange"></a>- 🌟Star FunASR: <a href='https://github.com/alibaba-damo-academy/FunASR/stargazers'><img src='https://img.shields.io/github/stars/alibaba-damo-academy/FunASR.svg?style=social'></a>- </div>- </div>- """)-# gradio interfacewith gr.Blocks() as demo:- #gr.Image("./examples/guide.png", show_label=False)gr.Markdown(top_md_1)gr.Markdown(top_md_2)gr.Markdown(top_md_3)diff --git a/funclip/argparse_tools.py b/funclip/utils/argparse_tools.pysimilarity index 100%rename from funclip/argparse_tools.pyrename to funclip/utils/argparse_tools.pydiff --git a/funclip/subtitle_utils.py b/funclip/utils/subtitle_utils.pysimilarity index 100%rename from funclip/subtitle_utils.pyrename to funclip/utils/subtitle_utils.pydiff --git a/funclip/trans_utils.py b/funclip/utils/trans_utils.pysimilarity index 100%rename from funclip/trans_utils.pyrename to funclip/utils/trans_utils.pydiff --git a/funclip/videoclipper.py b/funclip/videoclipper.pyindex f61f786..2ff0199 100644--- a/funclip/videoclipper.py+++ b/funclip/videoclipper.py@@ -10,9 +10,9 @@ import soundfile as sfimport moviepy.editor as mpyfrom moviepy.editor import *from moviepy.video.tools.subtitles import SubtitlesClip-from subtitle_utils import generate_srt, generate_srt_clip-from argparse_tools import ArgumentParser, get_commandline_args-from trans_utils import pre_proc, proc, write_state, load_state, proc_spk, convert_pcm_to_float+from utils.subtitle_utils import generate_srt, generate_srt_clip+from utils.argparse_tools import ArgumentParser, get_commandline_args+from utils.trans_utils import pre_proc, proc, write_state, load_state, proc_spk, convert_pcm_to_floatclass VideoClipper():