Skip to content

FunASR-powered video transcription, subtitle generation, and LLM-assisted clipping tool with a local Gradio UI.

update prompt and timestamp detect

维石9a7e21d13879
diff --git a/funclip/launch.py b/funclip/launch.py
index 9813c10..a669b2d 100644
--- a/funclip/launch.py
+++ b/funclip/launch.py
@@ -160,7 +160,7 @@ if __name__ == "__main__":
with gr.Column():
prompt_head = gr.Textbox(label="Prompt System", value=("你是一个视频srt字幕分析剪辑器,输入视频的srt字幕,"
"分析其中的精彩且尽可能连续的片段并裁剪出来,输出四条以内的片段,将片段中在时间上连续的多个句子及它们的时间戳合并为一条,"
- "注意确保文字与时间戳的正确匹配。输出需严格按照如下格式:1. [开始时间-结束时间] 文本"))
+ "注意确保文字与时间戳的正确匹配。输出需严格按照如下格式:1. [开始时间-结束时间] 文本,注意其中的连接符是“-”"))
prompt_head2 = gr.Textbox(label="Prompt User", value=("这是待裁剪的视频srt字幕:"))
with gr.Column():
with gr.Row():
diff --git a/funclip/utils/trans_utils.py b/funclip/utils/trans_utils.py
index 844fd62..a2cd03b 100644
--- a/funclip/utils/trans_utils.py
+++ b/funclip/utils/trans_utils.py
@@ -111,9 +111,9 @@ def convert_time_to_millis(time_str):
def extract_timestamps(input_text):
# 使用正则表达式查找所有时间戳
- timestamps = re.findall(r'\[(\d{2}:\d{2}:\d{2},\d{2,3})-(\d{2}:\d{2}:\d{2},\d{2,3})\]', input_text)
+ timestamps = re.findall(r'\[(\d{2}:\d{2}:\d{2},\d{2,3})\s*-\s*(\d{2}:\d{2}:\d{2},\d{2,3})\]', input_text)
times_list = []
-
+ print(timestamps)
# 循环遍历找到的所有时间戳,并转换为毫秒
for start_time, end_time in timestamps:
start_millis = convert_time_to_millis(start_time)