mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
8fc562a8ab
* add show_recording_waveform * add changeset * add animation * Refactor audio component and waveform options * formatting * add margin before audio controls * amend default values * expose gr.WaveformOptions * Tweak waveform options types and handle none * add waveform_options to reverse_audio * tweak bool typing * notebook --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
35 lines
685 B
Python
35 lines
685 B
Python
import os
|
|
|
|
import numpy as np
|
|
|
|
import gradio as gr
|
|
|
|
|
|
def reverse_audio(audio):
|
|
sr, data = audio
|
|
return (sr, np.flipud(data))
|
|
|
|
|
|
input_audio = gr.Audio(
|
|
sources=["microphone"],
|
|
waveform_options=gr.WaveformOptions(
|
|
waveform_color="#01C6FF",
|
|
waveform_progress_color="#0066B4",
|
|
skip_length=2,
|
|
show_controls=False,
|
|
),
|
|
)
|
|
demo = gr.Interface(
|
|
fn=reverse_audio,
|
|
inputs=input_audio,
|
|
outputs="audio",
|
|
examples=[
|
|
"https://samplelib.com/lib/preview/mp3/sample-3s.mp3",
|
|
os.path.join(os.path.dirname(__file__), "audio/recording1.wav"),
|
|
],
|
|
cache_examples=True,
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|