Spaces:
Sleeping
Sleeping
File size: 701 Bytes
fb1e679 dfaf883 fb1e679 aa02449 fb1e679 aa02449 fb1e679 |
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 |
import spaces
import gradio as gr
import numpy as np
from fastrtc import WebRTC, ReplyOnPause
@spaces.GPU
def hey():
pass
def response(audio: tuple[int, np.ndarray]):
"""This function must yield audio frames"""
...
yield audio
with gr.Blocks() as demo:
gr.HTML(
"""
<h1 style='text-align: center'>
Chat (Powered by WebRTC ⚡️)
</h1>
"""
)
with gr.Column():
with gr.Group():
audio = WebRTC(
mode="send-receive",
modality="audio",
)
audio.stream(fn=ReplyOnPause(response),
inputs=[audio], outputs=[audio],
time_limit=60)
demo.launch()
|