youngtsai commited on
Commit
56d1ceb
·
1 Parent(s): 0e729c5

generate_paragraph_history

Browse files
Files changed (1) hide show
  1. app.py +76 -36
app.py CHANGED
@@ -364,6 +364,34 @@ def generate_refine_paragraph(sys_content, eng_level, paragraph, user_refine_par
364
  def update_paragraph_refine_input(text):
365
  return text
366
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  def paragraph_save_and_tts(paragraph_text):
368
  """
369
  Saves the paragraph text and generates an audio file using OpenAI's TTS.
@@ -480,6 +508,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
480
  outputs=[topic_input]
481
  )
482
  return topic_radio
 
483
  # Step 3. 寫出段落要點
484
  with gr.Row():
485
  with gr.Column():
@@ -531,6 +560,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
531
  outputs=[points_input]
532
  )
533
  return points_radio
 
534
  # Step 4. 選定主題句
535
  with gr.Row():
536
  with gr.Column():
@@ -606,6 +636,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
606
  )
607
 
608
  return topic_sentences_radio
 
609
  # Step 5.寫出完整段落
610
  with gr.Row():
611
  with gr.Column():
@@ -684,7 +715,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
684
  inputs=[supporting_sentences_output],
685
  outputs= [supporting_sentences_input]
686
  )
687
-
688
  # Step 6. 寫出結論句
689
  with gr.Row():
690
  with gr.Column():
@@ -750,7 +781,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
750
  inputs=[conclusion_sentence_output],
751
  outputs= [conclusion_sentence_input]
752
  )
753
-
754
  # Step 7. 段落確認與修訂
755
  with gr.Row():
756
  with gr.Column():
@@ -1056,13 +1087,52 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1056
  paragraph_save_button = gr.Button("建立歷程回顧", variant="primary")
1057
  with gr.Row():
1058
  gr.Markdown("## 歷程回顧")
1059
- paragraph_save_output = gr.HTML(label="Save and Share")
1060
-
1061
  with gr.Row():
1062
- audio_output = gr.Audio(label="Generated Speech", type="filepath")
1063
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1064
 
1065
  paragraph_save_button.click(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1066
  fn=paragraph_save_and_tts,
1067
  inputs=[
1068
  paragraph_refine_input
@@ -1072,35 +1142,5 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1072
  audio_output
1073
  ]
1074
  )
1075
- # paragraph_history_make_button.click(
1076
- # fn=generate_paragraph_history,
1077
- # inputs=[
1078
- # topic_sentence_input,
1079
- # supporting_sentences_input,
1080
- # conclusion_sentence_input,
1081
- # paragraph_output,
1082
- # correct_grammatical_spelling_errors_output,
1083
- # refine_output_table,
1084
- # refine_output
1085
- # ],
1086
- # outputs=paragraph_save_output
1087
- # )
1088
-
1089
-
1090
-
1091
-
1092
-
1093
-
1094
-
1095
-
1096
-
1097
-
1098
-
1099
-
1100
-
1101
-
1102
-
1103
-
1104
-
1105
 
1106
  demo.launch()
 
364
  def update_paragraph_refine_input(text):
365
  return text
366
 
367
+ def generate_paragraph_history(scenario_input,
368
+ topic_output,
369
+ points_output,
370
+ topic_sentence_input,
371
+ supporting_sentences_input,
372
+ conclusion_sentence_input,
373
+ paragraph_output,
374
+ paragraph_evaluate_output,
375
+ correct_grammatical_spelling_errors_output_table,
376
+ refine_output_table,
377
+ refine_output):
378
+ """
379
+ 生成段落歷史紀錄
380
+ """
381
+
382
+ return scenario_input, \
383
+ topic_output, \
384
+ points_output, \
385
+ topic_sentence_input, \
386
+ supporting_sentences_input, \
387
+ conclusion_sentence_input, \
388
+ paragraph_output, \
389
+ paragraph_evaluate_output, \
390
+ correct_grammatical_spelling_errors_output_table, \
391
+ refine_output_table, \
392
+ refine_output
393
+
394
+
395
  def paragraph_save_and_tts(paragraph_text):
396
  """
397
  Saves the paragraph text and generates an audio file using OpenAI's TTS.
 
508
  outputs=[topic_input]
509
  )
510
  return topic_radio
511
+
512
  # Step 3. 寫出段落要點
513
  with gr.Row():
514
  with gr.Column():
 
560
  outputs=[points_input]
561
  )
562
  return points_radio
563
+
564
  # Step 4. 選定主題句
565
  with gr.Row():
566
  with gr.Column():
 
636
  )
637
 
638
  return topic_sentences_radio
639
+
640
  # Step 5.寫出完整段落
641
  with gr.Row():
642
  with gr.Column():
 
715
  inputs=[supporting_sentences_output],
716
  outputs= [supporting_sentences_input]
717
  )
718
+
719
  # Step 6. 寫出結論句
720
  with gr.Row():
721
  with gr.Column():
 
781
  inputs=[conclusion_sentence_output],
782
  outputs= [conclusion_sentence_input]
783
  )
784
+
785
  # Step 7. 段落確認與修訂
786
  with gr.Row():
787
  with gr.Column():
 
1087
  paragraph_save_button = gr.Button("建立歷程回顧", variant="primary")
1088
  with gr.Row():
1089
  gr.Markdown("## 歷程回顧")
 
 
1090
  with gr.Row():
1091
+ with gr.Accordion():
1092
+ scenario_input_history = gr.Textbox(label="情境")
1093
+ topic_input_history = gr.Textbox(label="主題")
1094
+ points_input_history = gr.Textbox(label="要點")
1095
+ topic_sentence_input_history = gr.Textbox(label="主題句")
1096
+ supporting_sentences_input_history = gr.Textbox(label="支持句")
1097
+ conclusion_sentence_input_history = gr.Textbox(label="結論句")
1098
+ paragraph_output_history = gr.Textbox(label="完整段落")
1099
+ paragraph_evaluate_output_history = gr.Dataframe(label="完整段落分析", wrap=True, column_widths=[35, 15, 50], interactive=False)
1100
+ correct_grammatical_spelling_errors_output_table_history = gr.Dataframe(label="修訂文法與拼字錯誤", interactive=False, wrap=True, column_widths=[30, 30, 40])
1101
+ refine_output_table_history = gr.Dataframe(label="段落改善建議", wrap=True, interactive=False, column_widths=[30, 30, 40])
1102
+ refine_output_history = gr.Textbox(label="修改建議")
1103
+ paragraph_save_output = gr.Textbox(label="最後結果")
1104
+ with gr.Row():
1105
+ audio_output = gr.Audio(label="音檔", type="filepath")
1106
 
1107
  paragraph_save_button.click(
1108
+ fn=generate_paragraph_history,
1109
+ inputs=[
1110
+ scenario_input,
1111
+ topic_input,
1112
+ points_input,
1113
+ topic_sentence_input,
1114
+ supporting_sentences_input,
1115
+ conclusion_sentence_input,
1116
+ paragraph_output,
1117
+ paragraph_evaluate_output,
1118
+ correct_grammatical_spelling_errors_output_table,
1119
+ refine_output_table,
1120
+ refine_output
1121
+ ],
1122
+ outputs=[
1123
+ scenario_input_history,
1124
+ topic_input_history,
1125
+ points_input_history,
1126
+ topic_sentence_input_history,
1127
+ supporting_sentences_input_history,
1128
+ conclusion_sentence_input_history,
1129
+ paragraph_output_history,
1130
+ paragraph_evaluate_output_history,
1131
+ correct_grammatical_spelling_errors_output_table_history,
1132
+ refine_output_table_history,
1133
+ refine_output_history,
1134
+ ]
1135
+ ).then(
1136
  fn=paragraph_save_and_tts,
1137
  inputs=[
1138
  paragraph_refine_input
 
1142
  audio_output
1143
  ]
1144
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1145
 
1146
  demo.launch()