gradio/demo/waveform/run.py
Dawood Khan ad9fb84f05
Improve make_waveform (#4918)
* make waveform animate

* fixes

* changelog

* fix

* Update CHANGELOG.md

* format

* fix

* changes

* add animate flag

* format

* fixes

* demo

* fixes

* lint

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2023-07-20 23:47:48 +03:00

30 lines
569 B
Python

import gradio as gr
import random
COLORS = [
["#ff0000", "#00ff00"],
["#00ff00", "#0000ff"],
["#0000ff", "#ff0000"],
]
def audio_waveform(audio, image):
return (
audio,
gr.make_waveform(audio),
gr.make_waveform(audio, animate=True),
gr.make_waveform(audio, bg_image=image, bars_color=random.choice(COLORS)),
)
gr.Interface(
audio_waveform,
inputs=[gr.Audio(), gr.Image(type="filepath")],
outputs=[
gr.Audio(),
gr.Video(),
gr.Video(),
gr.Video(),
],
).launch()