Spaces:
Running
Running
moment['transcript'] = ",".join([entry['text'] for entry in formatted_simple_transcript
Browse files
app.py
CHANGED
@@ -1277,19 +1277,19 @@ def generate_key_moments(formatted_simple_transcript, formatted_transcript):
|
|
1277 |
1. 小範圍切出不同段落的相對應時間軸的重點摘要,
|
1278 |
2. 每一小段最多不超過 1/5 的總內容,也就是大約 3~5段的重點(例如五~十分鐘的影片就一段大約1~2分鐘,最多三分鐘,但如果是超過十分鐘的影片,那一小段大約 2~3分鐘,以此類推)
|
1279 |
3. 注意不要遺漏任何一段時間軸的內容 從零秒開始
|
1280 |
-
4.
|
1281 |
-
5.
|
1282 |
-
以這種方式分析整個文本,從零秒開始分析,直到結束。這很重要
|
1283 |
6. 關鍵字從transcript extract to keyword,保留專家名字、專業術語、年份、數字、期刊名稱、地名、數學公式
|
1284 |
-
7. text,
|
1285 |
|
1286 |
-
|
|
|
1287 |
"start": "00:00",
|
1288 |
"end": "01:00",
|
1289 |
"text": "逐字稿的重點摘要",
|
1290 |
-
"transcript": "逐字稿的集合(要有合理的標點符號),要完整跟原來的一樣,不要省略",
|
1291 |
"keywords": ["關鍵字", "關鍵字"]
|
1292 |
-
|
|
|
1293 |
"""
|
1294 |
|
1295 |
try:
|
@@ -1337,8 +1337,18 @@ def generate_key_moments(formatted_simple_transcript, formatted_transcript):
|
|
1337 |
response = BEDROCK_CLIENT.invoke_model(**kwargs)
|
1338 |
response_body = json.loads(response.get('body').read())
|
1339 |
response_completion = response_body.get('content')[0].get('text')
|
|
|
|
|
1340 |
key_moments = json.loads(response_completion)["key_moments"]
|
1341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1342 |
print("=====key_moments=====")
|
1343 |
print(key_moments)
|
1344 |
print("=====key_moments=====")
|
|
|
1277 |
1. 小範圍切出不同段落的相對應時間軸的重點摘要,
|
1278 |
2. 每一小段最多不超過 1/5 的總內容,也就是大約 3~5段的重點(例如五~十分鐘的影片就一段大約1~2分鐘,最多三分鐘,但如果是超過十分鐘的影片,那一小段大約 2~3分鐘,以此類推)
|
1279 |
3. 注意不要遺漏任何一段時間軸的內容 從零秒開始
|
1280 |
+
4. 如果頭尾的情節不是重點,特別是打招呼或是介紹人物、或是say goodbye 就是不重要的情節,就不用擷取
|
1281 |
+
5. 以這種方式分析整個文本,從零秒開始分析,直到結束。這很重要
|
|
|
1282 |
6. 關鍵字從transcript extract to keyword,保留專家名字、專業術語、年份、數字、期刊名稱、地名、數學公式
|
1283 |
+
7. text, keywords please use or transfer zh-TW, it's very important
|
1284 |
|
1285 |
+
Example: retrun JSON
|
1286 |
+
{{key_moments:[{{
|
1287 |
"start": "00:00",
|
1288 |
"end": "01:00",
|
1289 |
"text": "逐字稿的重點摘要",
|
|
|
1290 |
"keywords": ["關鍵字", "關鍵字"]
|
1291 |
+
}}]
|
1292 |
+
}}
|
1293 |
"""
|
1294 |
|
1295 |
try:
|
|
|
1337 |
response = BEDROCK_CLIENT.invoke_model(**kwargs)
|
1338 |
response_body = json.loads(response.get('body').read())
|
1339 |
response_completion = response_body.get('content')[0].get('text')
|
1340 |
+
print(f"response_completion: {response_completion}")
|
1341 |
+
|
1342 |
key_moments = json.loads(response_completion)["key_moments"]
|
1343 |
|
1344 |
+
# "transcript": get text from formatted_simple_transcript
|
1345 |
+
for moment in key_moments:
|
1346 |
+
start_time = parse_time(moment['start'])
|
1347 |
+
end_time = parse_time(moment['end'])
|
1348 |
+
# 使用轉換後的 timedelta 物件進行時間
|
1349 |
+
moment['transcript'] = ",".join([entry['text'] for entry in formatted_simple_transcript
|
1350 |
+
if start_time <= parse_time(entry['start_time']) <= end_time])
|
1351 |
+
|
1352 |
print("=====key_moments=====")
|
1353 |
print(key_moments)
|
1354 |
print("=====key_moments=====")
|