RetellAI/retell-python-sdk

how to stream mic data into websocket?

Closed this issue · 3 comments

i was trying to send audio stream into the websocket. but i dont know what is the correct way to do it.
is there any guide to do that?
This is how i did it, But this is not working well. Thank you

p = pyaudio.PyAudio()

stream_in = p.open(format=pyaudio.paInt16, channels=1, rate=24000,
                   input=True, frames_per_buffer=512, input_device_index=1)


async def send_audio(websocket):
    while True:
        data = stream_in.read(2048)
        await websocket.send(data)

async def audio_client(uri):
    async with websockets.connect(uri) as websocket:
        send_task = asyncio.create_task(send_audio(websocket))
        await asyncio.gather(send_task)

callId = "45b8d11377f9b0548476d2d77de6f0ad"
websocket_uri = "wss://api.re-tell.ai/audio-websocket/"+callId
asyncio.run(audio_client(websocket_uri))

Hi @thilina15 . Would you like to try using retell LLM? https://docs.retellai.com/retell-llm/overview#single-prompt-llm-creation

This way you can get test calling done quickly instead of sending raw audio bytes.

If you prefer web call instead, you could use our react frontend sdk https://docs.retellai.com/make-calls/web-call

Thank you for your response @toddlzt . Actually I need to use my PC mic and speaker to make the call without using the web browser. (Mic and Speakers will be replaced with virtual audio cables in future)
So, basically what i need is a desktop client (not web client) for this retellAI.
Please guide me on this

Ah I see, I'm not an expert in this scenario. If you want to use nodejs backend I think you could hack it by installing the retell react sdk. Python backend audio is possible but requires translation the react sdk to python