youngtsai commited on
Commit
7e3c5ed
·
1 Parent(s): bdf71e2

worksheet_download_exam_result_button = gr.Button("轉成 word,完成後請點擊右下角 download 按鈕", variant="primary")

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -763,6 +763,18 @@ def generate_reading_passage(df_string):
763
 
764
  return reading_passage
765
 
 
 
 
 
 
 
 
 
 
 
 
 
766
  def text_to_speech(video_id, text):
767
  tts = gTTS(text, lang='en')
768
  filename = f'{video_id}_reading_passage.mp3'
@@ -1439,7 +1451,8 @@ def init_params(text, request: gr.Request):
1439
 
1440
  youtube_link = ""
1441
  password_text = ""
1442
- admin_update_visible = gr.update(visible=True)
 
1443
 
1444
  # if youtube_link in query_params
1445
  if "youtube_id" in request.query_params:
@@ -1451,9 +1464,10 @@ def init_params(text, request: gr.Request):
1451
  origin = request.headers.get("origin", "")
1452
  if "junyiacademy" in origin:
1453
  password_text = "6161"
1454
- admin_update_visible = gr.update(visible=False)
 
1455
 
1456
- return admin_update_visible, password_text, youtube_link
1457
 
1458
  HEAD = """
1459
  <meta charset="UTF-8">
@@ -1534,6 +1548,9 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
1534
  reading_passage = gr.Textbox(label="Reading Passage", lines=40, show_label=False)
1535
  reading_passage_speak_button = gr.Button("Speak", visible=False)
1536
  reading_passage_audio_output = gr.Audio(label="Audio Output", visible=False)
 
 
 
1537
  with gr.Tab("重點摘要"):
1538
  df_summarise = gr.Textbox(container=True, show_copy_button=True, lines=40, show_label=False)
1539
  with gr.Tab("教學備課"):
@@ -1560,7 +1577,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
1560
  worksheet_exam_result_prompt = gr.Textbox(visible=False)
1561
  worksheet_exam_result_original = gr.Textbox(visible=False)
1562
  worksheet_exam_result = gr.Textbox(label="初次生成結果", show_copy_button=True, interactive=True, lines=40)
1563
- worksheet_download_exam_result_button = gr.Button("將结果轉成 word,完成後請點擊右下角 download 按鈕", variant="primary")
1564
  worksheet_exam_result_word_link = gr.File(label="Download Word")
1565
 
1566
  with gr.Tab("課程計畫"):
@@ -1810,7 +1827,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
1810
  demo.load(
1811
  init_params,
1812
  inputs =[youtube_link],
1813
- outputs = [admin, password , youtube_link]
1814
  )
1815
 
1816
  demo.launch(allowed_paths=["videos"])
 
763
 
764
  return reading_passage
765
 
766
+ def edit_generate_reading():
767
+ # 將 reading_passage 設置為可編輯模式並顯示更新按鈕
768
+ return gr.update(interactive=True), gr.update(visible=True)
769
+
770
+ def update_reading_passage(new_content, video_id):
771
+ # 更新 GCS 上的 reading_passage 內容
772
+ # 此處假設已有函數 update_reading_passage_to_gcs 用於更新 GCS 內容
773
+ # update_reading_passage_to_gcs(video_id, new_content)
774
+ # 將 reading_passage 設置回唯讀模式並隱藏更新按鈕
775
+ return gr.update(value=new_content, interactive=False), gr.update(visible=False)
776
+
777
+
778
  def text_to_speech(video_id, text):
779
  tts = gTTS(text, lang='en')
780
  filename = f'{video_id}_reading_passage.mp3'
 
1451
 
1452
  youtube_link = ""
1453
  password_text = ""
1454
+ admin = gr.update(visible=True)
1455
+ reading_passage_admin = gr.update(visible=True)
1456
 
1457
  # if youtube_link in query_params
1458
  if "youtube_id" in request.query_params:
 
1464
  origin = request.headers.get("origin", "")
1465
  if "junyiacademy" in origin:
1466
  password_text = "6161"
1467
+ admin = gr.update(visible=False)
1468
+ reading_passage_admin = gr.update(visible=False)
1469
 
1470
+ return admin, reading_passage_admin, password_text, youtube_link
1471
 
1472
  HEAD = """
1473
  <meta charset="UTF-8">
 
1548
  reading_passage = gr.Textbox(label="Reading Passage", lines=40, show_label=False)
1549
  reading_passage_speak_button = gr.Button("Speak", visible=False)
1550
  reading_passage_audio_output = gr.Audio(label="Audio Output", visible=False)
1551
+ with gr.Row() as reading_passage_admin:
1552
+ reading_passage_edit_button = gr.Button("編輯")
1553
+ reading_passage_update_button = gr.Button("更新")
1554
  with gr.Tab("重點摘要"):
1555
  df_summarise = gr.Textbox(container=True, show_copy_button=True, lines=40, show_label=False)
1556
  with gr.Tab("教學備課"):
 
1577
  worksheet_exam_result_prompt = gr.Textbox(visible=False)
1578
  worksheet_exam_result_original = gr.Textbox(visible=False)
1579
  worksheet_exam_result = gr.Textbox(label="初次生成結果", show_copy_button=True, interactive=True, lines=40)
1580
+ worksheet_download_exam_result_button = gr.Button("轉成 word,完成後請點擊右下角 download 按鈕", variant="primary")
1581
  worksheet_exam_result_word_link = gr.File(label="Download Word")
1582
 
1583
  with gr.Tab("課程計畫"):
 
1827
  demo.load(
1828
  init_params,
1829
  inputs =[youtube_link],
1830
+ outputs = [admin, reading_passage_admin, password , youtube_link]
1831
  )
1832
 
1833
  demo.launch(allowed_paths=["videos"])