Spaces:
Sleeping
Sleeping
alex buz
commited on
Commit
·
d6410f9
1
Parent(s):
17e1343
new
Browse files
app.py
CHANGED
@@ -1,40 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
def transcribe():
|
22 |
-
return 'Success'
|
23 |
-
|
24 |
-
|
25 |
-
with gr.Blocks() as demo:
|
26 |
-
msg = gr.Textbox()
|
27 |
-
audio_box = gr.Audio(label="Audio", source="microphone", type="filepath", elem_id='audio')
|
28 |
-
|
29 |
-
with gr.Row():
|
30 |
-
audio_btn = gr.Button('Speak')
|
31 |
-
clear = gr.Button("Clear")
|
32 |
-
|
33 |
-
audio_btn.click(fn=action, inputs=audio_btn, outputs=audio_btn).\
|
34 |
-
then(fn=lambda: None, _js=click_js()).\
|
35 |
-
then(fn=check_btn, inputs=audio_btn).\
|
36 |
-
success(fn=transcribe, outputs=msg)
|
37 |
-
|
38 |
-
clear.click(lambda: None, None, msg, queue=False)
|
39 |
-
|
40 |
-
demo.queue().launch(debug=True)
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def save_audio(audio):
|
4 |
+
"""
|
5 |
+
This function simply returns the audio file it receives, simulating a save.
|
6 |
+
Gradio handles the recording directly in the browser.
|
7 |
+
"""
|
8 |
+
return audio
|
9 |
+
|
10 |
+
# Create a Gradio interface for recording audio
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=save_audio,
|
13 |
+
inputs=gr.Audio(source="microphone", type="file"),
|
14 |
+
outputs=gr.Audio(label="Playback Recorded Audio"),
|
15 |
+
title="Simple Browser-Based Voice Recorder",
|
16 |
+
description="Click 'Record' to start recording. Click 'Stop' to end recording. Playback the recording below."
|
17 |
+
)
|
18 |
+
|
19 |
+
# Run the Gradio app
|
20 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|