File size: 748 Bytes
5738222
 
 
debbc88
 
 
 
 
 
 
 
 
 
 
 
 
5738222
 
debbc88
 
 
5738222
 
 
 
 
debbc88
 
 
 
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
from fastrtc import Stream, ReplyOnPause, get_twilio_turn_credentials
from fastapi.responses import RedirectResponse
from gradio.utils import get_space
import numpy as np


def detection(audio: tuple[int, np.ndarray]):
    # Implement any iterator that yields audio
    # See "LLM Voice Chat" for a more complete example
    yield audio


stream = Stream(
    handler=ReplyOnPause(detection),
    modality="audio",
    mode="send-receive",
    rtc_configuration=get_twilio_turn_credentials() if get_space() else None,
    concurrency_limit=20 if get_space() else None,
)


@stream.get("/")
async def index():
    return RedirectResponse(url="/ui")


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(stream, host="0.0.0.0", port=7860)