pyVoIP
pyVoIP copied to clipboard
When using call.write_audio() to send audio, it is breaking
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.
Are you using Windows by chance?
Are you using Windows by chance?
yes