Fixed audio option

This commit is contained in:
Joan
2023-08-06 10:33:20 +02:00
parent 1276f64c40
commit b37bc826d3

View File

@@ -63,14 +63,14 @@ async def main(user, message_text, audio):
async with client: async with client:
audio_name, audio_duration = generate_audio(message_text) audio_name, audio_duration = generate_audio(message_text)
logging.info(f"Calling {user}") logging.info(f"Sending message to: {user}")
call = await voip_service.start_call(user)
await client.send_message(user, message_text) await client.send_message(user, message_text)
try: try:
if audio == 'yes': if audio == 'yes':
logging.info(f"Calling {user}")
call = await voip_service.start_call(user)
call.play(f"/data/audio/{audio_name}.raw") call.play(f"/data/audio/{audio_name}.raw")
except Exception as e:
logging.error(f"Error: {e}")
call_has_ended = False call_has_ended = False
@call.on_call_state_changed @call.on_call_state_changed
@@ -94,6 +94,8 @@ async def main(user, message_text, audio):
except Exception as e: except Exception as e:
logging.error(f"There was an error during the call: {e}") logging.error(f"There was an error during the call: {e}")
break break
except Exception as e:
logging.error(f"Error: {e}")
while True: while True:
time.sleep(5) time.sleep(5)