File size: 2,375 Bytes
0ad74ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import gradio as gr
with gr.Blocks() as demo:
with gr.Row():
with gr.Column():
input_audio = gr.Audio(type="filepath", label="Input Audio", sources=["upload", "microphone"])
with gr.Column():
output_audio = gr.Audio(label="Output Audio", sources=["upload", "microphone"])
with gr.Row():
with gr.Column():
input_num_change = gr.Number(label="# Input Change Events", value=0)
input_num_input = gr.Number(label="# Input Input Events", value=0)
input_num_load = gr.Number(label="# Input Upload Events", value=0)
input_num_play = gr.Number(label="# Input Play Events", value=0)
input_num_pause = gr.Number(label="# Input Pause Events", value=0)
with gr.Column():
input_record = gr.Number(label="# Input Start Recording Events", value=0)
input_pause = gr.Number(label="# Input Pause Recording Events", value=0)
input_stop = gr.Number(label="# Input Stop Recording Events", value=0)
with gr.Column():
output_num_play = gr.Number(label="# Output Play Events", value=0)
output_num_pause = gr.Number(label="# Output Pause Events", value=0)
output_num_stop = gr.Number(label="# Output Stop Events", value=0)
input_audio.upload(lambda s, n: (s, n + 1), [input_audio, input_num_load], [output_audio, input_num_load])
input_audio.change(lambda n: n + 1, input_num_change, input_num_change)
input_audio.play(lambda n: n + 1, input_num_play, input_num_play)
input_audio.pause(lambda n: n + 1, input_num_pause, input_num_pause)
input_audio.change(lambda n: n + 1, input_num_change, input_num_change)
input_audio.input(lambda n: n + 1, input_num_input, input_num_input)
input_audio.start_recording(lambda n: n + 1, input_record, input_record)
input_audio.pause_recording(lambda n: n + 1, input_pause, input_pause)
input_audio.stop_recording(lambda n: n + 1, input_stop, input_stop)
output_audio.play(lambda n: n + 1, output_num_play, output_num_play)
output_audio.pause(lambda n: n + 1, output_num_pause, output_num_pause)
output_audio.stop(lambda n: n + 1, output_num_stop, output_num_stop)
if __name__ == "__main__":
demo.launch()
|