Spaces:
Sleeping
Sleeping
Update app.py
Browse filesASR + TTS _ V1
app.py
CHANGED
@@ -17,7 +17,7 @@ def process_audio(audio_data):
|
|
17 |
if audio_data is None:
|
18 |
return "No audio provided.", ""
|
19 |
|
20 |
-
#
|
21 |
if isinstance(audio_data, tuple):
|
22 |
sample_rate, data = audio_data
|
23 |
else:
|
@@ -49,20 +49,20 @@ def process_audio(audio_data):
|
|
49 |
recognized_text = "The ASR module is still loading, please press the button again!"
|
50 |
return recognized_text, ""
|
51 |
|
52 |
-
#
|
53 |
def disable_components():
|
54 |
-
#
|
55 |
-
recognized_text_update = gr.update(value='Voice
|
56 |
-
#
|
57 |
process_button_update = gr.update(interactive=False)
|
58 |
-
#
|
59 |
loading_animation_update = gr.update(visible=True)
|
60 |
return recognized_text_update, process_button_update, loading_animation_update
|
61 |
|
62 |
-
#
|
63 |
def enable_components(recognized_text):
|
64 |
process_button_update = gr.update(interactive=True)
|
65 |
-
#
|
66 |
loading_animation_update = gr.update(visible=False)
|
67 |
return recognized_text, process_button_update, loading_animation_update
|
68 |
|
@@ -142,7 +142,6 @@ def create_interface():
|
|
142 |
outputs=[],
|
143 |
)
|
144 |
|
145 |
-
|
146 |
# Audio input section
|
147 |
with gr.Row():
|
148 |
audio_input = gr.Audio(
|
@@ -150,7 +149,7 @@ def create_interface():
|
|
150 |
type="numpy", # Get audio data and sample rate
|
151 |
label="Say Something..."
|
152 |
)
|
153 |
-
recognized_text = gr.Textbox(label="Recognized Text",interactive=False)
|
154 |
|
155 |
# Process audio button
|
156 |
process_button = gr.Button("Process Audio")
|
|
|
17 |
if audio_data is None:
|
18 |
return "No audio provided.", ""
|
19 |
|
20 |
+
# Check if audio_data is a tuple and extract data
|
21 |
if isinstance(audio_data, tuple):
|
22 |
sample_rate, data = audio_data
|
23 |
else:
|
|
|
49 |
recognized_text = "The ASR module is still loading, please press the button again!"
|
50 |
return recognized_text, ""
|
51 |
|
52 |
+
# Define a function to disable the button and display a loading indicator
|
53 |
def disable_components():
|
54 |
+
# Update recognized_text content, indicating that processing is ongoing
|
55 |
+
recognized_text_update = gr.update(value='Voice Recognition Running...')
|
56 |
+
# Disable process_button
|
57 |
process_button_update = gr.update(interactive=False)
|
58 |
+
# Display loading animation
|
59 |
loading_animation_update = gr.update(visible=True)
|
60 |
return recognized_text_update, process_button_update, loading_animation_update
|
61 |
|
62 |
+
# Define a function to enable the button and hide the loading indicator
|
63 |
def enable_components(recognized_text):
|
64 |
process_button_update = gr.update(interactive=True)
|
65 |
+
# Hide loading animation
|
66 |
loading_animation_update = gr.update(visible=False)
|
67 |
return recognized_text, process_button_update, loading_animation_update
|
68 |
|
|
|
142 |
outputs=[],
|
143 |
)
|
144 |
|
|
|
145 |
# Audio input section
|
146 |
with gr.Row():
|
147 |
audio_input = gr.Audio(
|
|
|
149 |
type="numpy", # Get audio data and sample rate
|
150 |
label="Say Something..."
|
151 |
)
|
152 |
+
recognized_text = gr.Textbox(label="Recognized Text", interactive=False)
|
153 |
|
154 |
# Process audio button
|
155 |
process_button = gr.Button("Process Audio")
|