add debug infos

This commit is contained in:
Moritz 2024-08-14 09:44:17 +02:00
parent 01f661d37b
commit 1e9beec018

View file

@ -10,10 +10,12 @@ def audio_callback_closure(client: AsyncClient):
f"Audio received in room {room.display_name}\n" f"Audio received in room {room.display_name}\n"
f"{room.user_name(event.sender)} | {event.body} | {event.url}" f"{room.user_name(event.sender)} | {event.body} | {event.url}"
) )
print("Download audio")
audio = await client.download(event.url) audio = await client.download(event.url)
files = {'audio_file': audio.body} files = {'audio_file': audio.body}
#with open("/tmp/audiofile",'bw') as file: #with open("/tmp/audiofile",'bw') as file:
# file.write(audio.body) # file.write(audio.body)
print("Transcribe audio")
response = requests.post('http://127.0.0.1:9000/asr?encode=true&task=transcribe&word_timestamps=false&output=txt', files=files) response = requests.post('http://127.0.0.1:9000/asr?encode=true&task=transcribe&word_timestamps=false&output=txt', files=files)
room_id = room.room_id room_id = room.room_id
await client.room_send( await client.room_send(
@ -29,6 +31,7 @@ async def main() -> None:
homeserver = str(os.getenv("HOMESERVER")) homeserver = str(os.getenv("HOMESERVER"))
user = str(os.getenv("USER")) user = str(os.getenv("USER"))
password = str(os.getenv("PASSWORD")) password = str(os.getenv("PASSWORD"))
print(f"login at {homeserver} with {user}")
client = AsyncClient(homeserver, user) client = AsyncClient(homeserver, user)
client.add_event_callback(audio_callback_closure(client), RoomMessageAudio) client.add_event_callback(audio_callback_closure(client), RoomMessageAudio)