Norphel commited on
Commit
cbf2f18
·
verified ·
1 Parent(s): fe6458d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -14
app.py CHANGED
@@ -1,19 +1,25 @@
1
- import gradio as gr
2
- import shutil
3
 
4
- def process_audio(audio_path):
5
- # Define a location to save the audio file
6
- saved_path = "saved_audio.wav"
7
- shutil.copy(audio_path, saved_path) # Save the recorded file
8
 
9
- return saved_path # Return the file path for playback
 
 
10
 
11
- iface = gr.Interface(
12
- fn=process_audio,
13
- inputs=gr.Audio(source="microphone", type="filepath"), # Records & provides a file path
14
- outputs=gr.Audio(type="filepath"), # Plays back the recorded audio
15
- title="Record & Play Audio",
16
- description="Press record, speak, and listen to your recorded audio."
 
 
 
 
 
 
 
17
  )
18
 
19
- iface.launch()
 
 
1
+ import numpy as np
 
2
 
3
+ import gradio as gr
 
 
 
4
 
5
+ def reverse_audio(audio):
6
+ sr, data = audio
7
+ return (sr, np.flipud(data))
8
 
9
+ input_audio = gr.Audio(
10
+ sources=["microphone"],
11
+ waveform_options=gr.WaveformOptions(
12
+ waveform_color="#01C6FF",
13
+ waveform_progress_color="#0066B4",
14
+ skip_length=2,
15
+ show_controls=False,
16
+ ),
17
+ )
18
+ demo = gr.Interface(
19
+ fn=reverse_audio,
20
+ inputs=input_audio,
21
+ outputs="audio"
22
  )
23
 
24
+ if __name__ == "__main__":
25
+ demo.launch()