pyVoIP icon indicating copy to clipboard operation
pyVoIP copied to clipboard

When using call.write_audio() to send audio, it is breaking

Open PraveenChordia opened this issue 2 years ago • 2 comments

ws_url = "ws://localhost:8000/listen2"
ws = connect(ws_url)

def ws_thread():
    while call.state == CallState.ANSWERED:
        message = json.loads(ws.recv())
        if 'bot_voice' in message.keys() and message['bot_voice'] != '':
            bot_voice = message['bot_voice']
            bot_voice = bot_voice.encode('utf-8')
            bot_voice_bytes = base64.b64decode(bot_voice)
            call.write_audio(bot_voice_bytes)
        else:
            print(message['message'])
    ws.close()

t = threading.Thread(target=ws_thread)
t.start()

This is the code I am using. I am getting the audio and it is playing fine but it breaks sometimes in between randomly at different times in different calls.

PraveenChordia avatar Apr 06 '23 15:04 PraveenChordia

Are you using Windows by chance?

tayler6000 avatar May 09 '23 05:05 tayler6000

Are you using Windows by chance?

yes

PraveenChordia avatar May 09 '23 09:05 PraveenChordia