Spaces:
Sleeping
Sleeping
SefyanKehail
commited on
Commit
·
025ccb1
1
Parent(s):
709cec1
added microphone recording and uploading event listener
Browse files
app.py
CHANGED
|
@@ -254,9 +254,16 @@ def output_conf():
|
|
| 254 |
|
| 255 |
def enable_convert_button(audio):
|
| 256 |
if audio is not None:
|
| 257 |
-
return gr.update(interactive=True)
|
| 258 |
-
return gr.update(interactive=False)
|
| 259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
|
| 261 |
def get_gui(theme):
|
| 262 |
with gr.Blocks(theme=theme) as app:
|
|
@@ -271,10 +278,12 @@ def get_gui(theme):
|
|
| 271 |
envel_r = envelope_ratio_conf()
|
| 272 |
const = consonant_protec_conf()
|
| 273 |
button_base = button_conf()
|
|
|
|
| 274 |
output_base = output_conf()
|
|
|
|
|
|
|
| 275 |
|
| 276 |
-
aud.change(enable_convert_button, inputs=[aud], outputs=[button_base])
|
| 277 |
-
|
| 278 |
|
| 279 |
button_base.click(
|
| 280 |
run,
|
|
|
|
| 254 |
|
| 255 |
def enable_convert_button(audio):
|
| 256 |
if audio is not None:
|
| 257 |
+
return gr.update(interactive=True), gr.update(value="", visible=False)
|
| 258 |
+
return gr.update(interactive=False), None
|
| 259 |
|
| 260 |
+
def recording_info():
|
| 261 |
+
return gr.Markdown("", visible=False)
|
| 262 |
+
|
| 263 |
+
def stop_recording_info(audio):
|
| 264 |
+
if audio is None:
|
| 265 |
+
return gr.update(value="### <i style='color:yellow'>Recording and uploading...</i>", visible=True)
|
| 266 |
+
return gr.update(value="", visible=False)
|
| 267 |
|
| 268 |
def get_gui(theme):
|
| 269 |
with gr.Blocks(theme=theme) as app:
|
|
|
|
| 278 |
envel_r = envelope_ratio_conf()
|
| 279 |
const = consonant_protec_conf()
|
| 280 |
button_base = button_conf()
|
| 281 |
+
info = recording_info
|
| 282 |
output_base = output_conf()
|
| 283 |
+
|
| 284 |
+
aud.start_recording(stop_recording_info, inputs=[aud], outputs=[info])
|
| 285 |
|
| 286 |
+
aud.change(enable_convert_button, inputs=[aud], outputs=[button_base, info])
|
|
|
|
| 287 |
|
| 288 |
button_base.click(
|
| 289 |
run,
|