import gradio as gr from audio_streaming_client import AudioStreamingClient audio_streaming_client = AudioStreamingClient() audio_streaming_client.start() def stream_audio(audio): sample_rate = audio[0] audio_streaming_client.put_audio(audio[1], sample_rate) output_size = len(audio[1]) output_audio = audio_streaming_client.get_audio(sample_rate, output_size) return (sample_rate, output_audio) with gr.Blocks() as demo: gr.Markdown("# Speech to speech in an inference endpoint 🎤") inp = gr.Audio(sources=["microphone"], type="numpy") out = gr.Audio(streaming=True, autoplay=True) inp.stream(stream_audio, inp, out, time_limit=600, stream_every=1) demo.launch()