Spaces:
Sleeping
Sleeping
add junyi_link
Browse files
app.py
CHANGED
@@ -766,7 +766,21 @@ def process_youtube_link(password, link, LLM_model=None):
|
|
766 |
reading_passage, \
|
767 |
subject, \
|
768 |
grade
|
769 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
770 |
def create_formatted_simple_transcript(transcript):
|
771 |
formatted_simple_transcript = []
|
772 |
for entry in transcript:
|
@@ -3546,6 +3560,7 @@ def create_app():
|
|
3546 |
with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD, js=JS, css=CSS) as demo:
|
3547 |
with gr.Row() as admin:
|
3548 |
password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
|
|
|
3549 |
youtube_link = gr.Textbox(label="Enter YouTube Link", elem_id="youtube_link_input", visible=True)
|
3550 |
video_id = gr.Textbox(label="video_id", visible=True)
|
3551 |
# file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
|
@@ -4131,6 +4146,21 @@ def create_app():
|
|
4131 |
ai_chatbot_question_2,
|
4132 |
ai_chatbot_question_3
|
4133 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4134 |
|
4135 |
youtube_link.input(
|
4136 |
process_youtube_link,
|
|
|
766 |
reading_passage, \
|
767 |
subject, \
|
768 |
grade
|
769 |
+
|
770 |
+
def process_junyi_link_to_youtube_link(junyi_link):
|
771 |
+
print("====process_junyi_link_to_youtube_link====")
|
772 |
+
print(junyi_link)
|
773 |
+
|
774 |
+
# 辨識 /v/{youtube_id}
|
775 |
+
import re
|
776 |
+
match = re.search(r"/v/([\w-]+)", junyi_link)
|
777 |
+
if match:
|
778 |
+
youtube_id = match.group(1)
|
779 |
+
youtube_link = f"https://www.youtube.com/watch?v={youtube_id}"
|
780 |
+
return youtube_link
|
781 |
+
else:
|
782 |
+
return junyi_link
|
783 |
+
|
784 |
def create_formatted_simple_transcript(transcript):
|
785 |
formatted_simple_transcript = []
|
786 |
for entry in transcript:
|
|
|
3560 |
with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD, js=JS, css=CSS) as demo:
|
3561 |
with gr.Row() as admin:
|
3562 |
password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
|
3563 |
+
junyi_link = gr.Textbox(label="Junyi Link", elem_id="junyi_link_input", visible=True)
|
3564 |
youtube_link = gr.Textbox(label="Enter YouTube Link", elem_id="youtube_link_input", visible=True)
|
3565 |
video_id = gr.Textbox(label="video_id", visible=True)
|
3566 |
# file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
|
|
|
4146 |
ai_chatbot_question_2,
|
4147 |
ai_chatbot_question_3
|
4148 |
]
|
4149 |
+
|
4150 |
+
junyi_link.input(
|
4151 |
+
process_junyi_link_to_youtube_link,
|
4152 |
+
inputs=[junyi_link],
|
4153 |
+
outputs=[youtube_link]
|
4154 |
+
).then(
|
4155 |
+
process_youtube_link,
|
4156 |
+
inputs=process_youtube_link_inputs,
|
4157 |
+
outputs=process_youtube_link_outputs
|
4158 |
+
).then(
|
4159 |
+
update_state,
|
4160 |
+
inputs=update_state_inputs,
|
4161 |
+
outputs=update_state_outputs
|
4162 |
+
)
|
4163 |
+
|
4164 |
|
4165 |
youtube_link.input(
|
4166 |
process_youtube_link,
|