Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1040,52 +1040,52 @@ def create_gradio_interface(model_path: str, default_max_tokens: int = 8192, att
|
|
| 1040 |
label="Play individual segments to verify accuracy"
|
| 1041 |
)
|
| 1042 |
|
| 1043 |
-
#
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
|
| 1049 |
-
|
| 1050 |
-
|
| 1051 |
-
|
| 1052 |
-
|
| 1053 |
-
|
| 1054 |
-
|
| 1055 |
-
|
| 1056 |
-
|
| 1057 |
-
|
| 1058 |
-
|
| 1059 |
-
|
| 1060 |
-
|
| 1061 |
-
|
| 1062 |
-
|
| 1063 |
-
|
| 1064 |
-
|
| 1065 |
-
|
| 1066 |
-
|
| 1067 |
-
|
| 1068 |
-
|
| 1069 |
-
|
| 1070 |
-
|
| 1071 |
-
|
| 1072 |
-
|
| 1073 |
-
|
| 1074 |
-
|
| 1075 |
-
|
| 1076 |
-
|
| 1077 |
-
|
| 1078 |
-
|
| 1079 |
-
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
|
| 1090 |
# Add examples
|
| 1091 |
gr.Markdown("## 📋 Instructions")
|
|
@@ -1137,6 +1137,6 @@ if __name__ == "__main__":
|
|
| 1137 |
demo.launch(
|
| 1138 |
show_error=True,
|
| 1139 |
theme=gr.themes.Soft(),
|
| 1140 |
-
|
| 1141 |
# 不要加 server_name, server_port, share
|
| 1142 |
)
|
|
|
|
| 1040 |
label="Play individual segments to verify accuracy"
|
| 1041 |
)
|
| 1042 |
|
| 1043 |
+
# Event handlers
|
| 1044 |
+
do_sample_checkbox.change(
|
| 1045 |
+
fn=lambda x: gr.update(visible=x),
|
| 1046 |
+
inputs=[do_sample_checkbox],
|
| 1047 |
+
outputs=[sampling_params]
|
| 1048 |
+
)
|
| 1049 |
+
|
| 1050 |
+
def reset_stop_flag():
|
| 1051 |
+
"""Reset stop flag before starting transcription."""
|
| 1052 |
+
global stop_generation_flag
|
| 1053 |
+
stop_generation_flag = False
|
| 1054 |
+
|
| 1055 |
+
def set_stop_flag():
|
| 1056 |
+
"""Set stop flag to interrupt generation."""
|
| 1057 |
+
global stop_generation_flag
|
| 1058 |
+
stop_generation_flag = True
|
| 1059 |
+
return "⏹️ Stop requested..."
|
| 1060 |
+
|
| 1061 |
+
transcribe_button.click(
|
| 1062 |
+
fn=reset_stop_flag,
|
| 1063 |
+
inputs=[],
|
| 1064 |
+
outputs=[],
|
| 1065 |
+
queue=False
|
| 1066 |
+
).then(
|
| 1067 |
+
fn=transcribe_audio,
|
| 1068 |
+
inputs=[
|
| 1069 |
+
audio_input,
|
| 1070 |
+
audio_path_input,
|
| 1071 |
+
start_time_input,
|
| 1072 |
+
end_time_input,
|
| 1073 |
+
max_tokens_slider,
|
| 1074 |
+
temperature_slider,
|
| 1075 |
+
top_p_slider,
|
| 1076 |
+
do_sample_checkbox,
|
| 1077 |
+
repetition_penalty_slider,
|
| 1078 |
+
context_info_input
|
| 1079 |
+
],
|
| 1080 |
+
outputs=[raw_output, audio_segments_output]
|
| 1081 |
+
)
|
| 1082 |
+
|
| 1083 |
+
stop_button.click(
|
| 1084 |
+
fn=set_stop_flag,
|
| 1085 |
+
inputs=[],
|
| 1086 |
+
outputs=[raw_output],
|
| 1087 |
+
queue=False
|
| 1088 |
+
)
|
| 1089 |
|
| 1090 |
# Add examples
|
| 1091 |
gr.Markdown("## 📋 Instructions")
|
|
|
|
| 1137 |
demo.launch(
|
| 1138 |
show_error=True,
|
| 1139 |
theme=gr.themes.Soft(),
|
| 1140 |
+
css=custom_css
|
| 1141 |
# 不要加 server_name, server_port, share
|
| 1142 |
)
|