Spaces:
Sleeping
Sleeping
fixed clear button
Browse files
app.py
CHANGED
@@ -137,6 +137,11 @@ def create_new_websocket_connection():
|
|
137 |
threading.Thread(target=connections[client_id].run, daemon=True).start()
|
138 |
return client_id
|
139 |
|
|
|
|
|
|
|
|
|
|
|
140 |
if __name__ == "__main__":
|
141 |
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
142 |
gr.Markdown(f"# Realtime transcription demo")
|
@@ -150,8 +155,7 @@ if __name__ == "__main__":
|
|
150 |
clear_button = gr.Button("Clear")
|
151 |
|
152 |
client_id = gr.State()
|
153 |
-
|
154 |
-
clear_button.click(lambda: None, outputs=[state]).then(lambda: "", outputs=[output_textbox])
|
155 |
audio_input.stream(send_audio_chunk, [audio_input, client_id], [output_textbox], stream_every=0.5, concurrency_limit=None)
|
156 |
demo.load(create_new_websocket_connection, outputs=[client_id])
|
157 |
|
|
|
137 |
threading.Thread(target=connections[client_id].run, daemon=True).start()
|
138 |
return client_id
|
139 |
|
140 |
+
def clear_transcript(client_id):
|
141 |
+
if client_id in connections:
|
142 |
+
connections[client_id].transcript = ""
|
143 |
+
return ""
|
144 |
+
|
145 |
if __name__ == "__main__":
|
146 |
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
147 |
gr.Markdown(f"# Realtime transcription demo")
|
|
|
155 |
clear_button = gr.Button("Clear")
|
156 |
|
157 |
client_id = gr.State()
|
158 |
+
clear_button.click(clear_transcript, inputs=[client_id], outputs=[output_textbox])
|
|
|
159 |
audio_input.stream(send_audio_chunk, [audio_input, client_id], [output_textbox], stream_every=0.5, concurrency_limit=None)
|
160 |
demo.load(create_new_websocket_connection, outputs=[client_id])
|
161 |
|