youngtsai commited on
Commit
ac12d84
1 Parent(s): d230f8b

html_content

Browse files
Files changed (1) hide show
  1. app.py +34 -40
app.py CHANGED
@@ -54,6 +54,9 @@ OUTPUT_PATH = 'videos'
54
  OPEN_AI_KEY = os.getenv("OPEN_AI_KEY")
55
  client = OpenAI(api_key=OPEN_AI_KEY)
56
 
 
 
 
57
  # # ====drive====初始化Google Drive服务
58
  def init_drive_service():
59
  credentials_json_string = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON")
@@ -324,6 +327,23 @@ def format_transcript_to_html(formatted_transcript):
324
  # html_content += f"<img src='{entry['screenshot_path']}' width='500px' />"
325
  # return html_content
326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  # 将逐字稿数据转换为 JavaScript 对象数组
328
  entries_js_array = ',\n '.join([
329
  json.dumps({
@@ -334,40 +354,7 @@ def format_transcript_to_html(formatted_transcript):
334
  }, ensure_ascii=False) for entry in formatted_transcript
335
  ])
336
 
337
- # 创建 HTML 内容
338
- html_content = f"""
339
- <!DOCTYPE html>
340
- <html>
341
- <head>
342
- <title>Transcript Viewer</title>
343
- <style>
344
- #contentDisplay {{
345
- width: 500px;
346
- margin: auto;
347
- text-align: center;
348
- }}
349
- #imageDisplay {{
350
- width: 500px;
351
- height: 300px;
352
- background-color: #f0f0f0;
353
- background-size: contain;
354
- background-position: center center;
355
- background-repeat: no-repeat;
356
- margin-bottom: 20px;
357
- }}
358
- </style>
359
- </head>
360
- <body>
361
-
362
- <div id="contentDisplay">
363
- <div id="imageDisplay"></div>
364
- <h3 id="timeDisplay"></h3>
365
- <p id="textDisplay"></p>
366
- </div>
367
- <button id="prevButton">Previous</button>
368
- <button id="nextButton">Next</button>
369
-
370
- <script>
371
  var entries = [
372
  {entries_js_array}
373
  ];
@@ -394,12 +381,19 @@ def format_transcript_to_html(formatted_transcript):
394
  currentIndex += 1;
395
  updateContentDisplay(currentIndex);
396
  }}
397
- }});
398
- </script>
399
 
400
- </body>
401
- </html>
402
- """
 
 
 
 
 
 
 
403
 
404
  return html_content
405
 
@@ -551,7 +545,7 @@ def respond(user_message, df_string_output, chat_history):
551
  # 返回聊天历史和空字符串清空输入框
552
  return "", chat_history
553
 
554
- with gr.Blocks() as demo:
555
  with gr.Row():
556
  with gr.Column():
557
  file_upload = gr.File(label="Upload your CSV or Word file")
 
54
  OPEN_AI_KEY = os.getenv("OPEN_AI_KEY")
55
  client = OpenAI(api_key=OPEN_AI_KEY)
56
 
57
+ JS = ''
58
+ CSS = ''
59
+
60
  # # ====drive====初始化Google Drive服务
61
  def init_drive_service():
62
  credentials_json_string = os.getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON")
 
327
  # html_content += f"<img src='{entry['screenshot_path']}' width='500px' />"
328
  # return html_content
329
 
330
+ CSS = """
331
+ #contentDisplay {{
332
+ width: 500px;
333
+ margin: auto;
334
+ text-align: center;
335
+ }}
336
+ #imageDisplay {{
337
+ width: 500px;
338
+ height: 300px;
339
+ background-color: #f0f0f0;
340
+ background-size: contain;
341
+ background-position: center center;
342
+ background-repeat: no-repeat;
343
+ margin-bottom: 20px;
344
+ }}
345
+ """
346
+
347
  # 将逐字稿数据转换为 JavaScript 对象数组
348
  entries_js_array = ',\n '.join([
349
  json.dumps({
 
354
  }, ensure_ascii=False) for entry in formatted_transcript
355
  ])
356
 
357
+ JS = f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  var entries = [
359
  {entries_js_array}
360
  ];
 
381
  currentIndex += 1;
382
  updateContentDisplay(currentIndex);
383
  }}
384
+ }});
385
+ """
386
 
387
+ # 创建 HTML 内容
388
+ html_content = """
389
+ <div id="contentDisplay">
390
+ <div id="imageDisplay"></div>
391
+ <h3 id="timeDisplay"></h3>
392
+ <p id="textDisplay"></p>
393
+ </div>
394
+ <button id="prevButton">Previous</button>
395
+ <button id="nextButton">Next</button>
396
+ """
397
 
398
  return html_content
399
 
 
545
  # 返回聊天历史和空字符串清空输入框
546
  return "", chat_history
547
 
548
+ with gr.Blocks(css=CSS, js=JS) as demo:
549
  with gr.Row():
550
  with gr.Column():
551
  file_upload = gr.File(label="Upload your CSV or Word file")