| import os | |
| import gradio as gr | |
| def reverse_audio(audio): | |
| sr, data = audio | |
| return audio | |
| with gr.Blocks(title="Mic Test") as demo: | |
| src = "https://onj.me/shorts/audio/02-Who%27s%20the%20bossa%21.mp3" | |
| gr.HTML(f"<audio src='{src}' autoplay controls></audio>", visible=True) | |
| mic = gr.Audio( | |
| sources=["microphone"], | |
| waveform_options=gr.WaveformOptions( | |
| waveform_color="#01C6FF", | |
| waveform_progress_color="#0066B4", | |
| skip_length=2, | |
| show_controls=False, | |
| ), | |
| ) | |
| mic.stop_recording( | |
| fn=reverse_audio, | |
| inputs=mic, | |
| outputs=gr.Audio() | |
| ) | |
| demo.launch() | |