Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ def check_transcript(transcript, threshold=10):
|
|
15 |
lines = transcript.split('\n')
|
16 |
# 初始化變量以儲存時間戳
|
17 |
end_times = []
|
|
|
18 |
|
19 |
for line in lines:
|
20 |
if " - " in line:
|
@@ -24,18 +25,20 @@ def check_transcript(transcript, threshold=10):
|
|
24 |
h, m, s = map(int, time_str.split(":"))
|
25 |
total_seconds = h * 3600 + m * 60 + s
|
26 |
end_times.append(total_seconds)
|
27 |
-
|
|
|
|
|
28 |
# 檢查時間戳之間的間隔
|
29 |
gaps = []
|
30 |
for i in range(1, len(end_times)):
|
31 |
gap = end_times[i] - end_times[i-1]
|
32 |
if gap > threshold:
|
33 |
-
gaps.append(f"發現時間間隔過長: {gap:.2f}
|
34 |
|
35 |
if not gaps:
|
36 |
return "逐字稿無漏掉部分。"
|
37 |
else:
|
38 |
-
return "\n".join(gaps)
|
39 |
|
40 |
# 建立 Gradio 界面
|
41 |
iface = gr.Interface(
|
|
|
15 |
lines = transcript.split('\n')
|
16 |
# 初始化變量以儲存時間戳
|
17 |
end_times = []
|
18 |
+
contents = [] # 儲存對應的文字內容
|
19 |
|
20 |
for line in lines:
|
21 |
if " - " in line:
|
|
|
25 |
h, m, s = map(int, time_str.split(":"))
|
26 |
total_seconds = h * 3600 + m * 60 + s
|
27 |
end_times.append(total_seconds)
|
28 |
+
# 提取文字內容
|
29 |
+
contents.append(line)
|
30 |
+
|
31 |
# 檢查時間戳之間的間隔
|
32 |
gaps = []
|
33 |
for i in range(1, len(end_times)):
|
34 |
gap = end_times[i] - end_times[i-1]
|
35 |
if gap > threshold:
|
36 |
+
gaps.append(f"發現時間間隔過長: {gap:.2f} 秒,發生於:\n上一句:{contents[i-1]}\n下一句:{contents[i]}")
|
37 |
|
38 |
if not gaps:
|
39 |
return "逐字稿無漏掉部分。"
|
40 |
else:
|
41 |
+
return "\n\n".join(gaps)
|
42 |
|
43 |
# 建立 Gradio 界面
|
44 |
iface = gr.Interface(
|