Closed antyser closed 2 months ago
Hi @antyser
Based on what you have given here, it looks like you either:
encoding
and sample_rate
values in the Options and DG is unable to determine what kind of audio stream it is (ie you might be pushing audio bytes, but it doesnt know what kind of audio). interview = await get_interview(interview_id)
if not interview:
logger.error(f"Interview not found: {interview_id}")
raise HTTPException(status_code=404, detail="Interview not found")
If this code is enabled, it cannot produce anything. Do you know what could cause the issue?
I think it is pushing the audio to DG because when I disabled it, I can see the transcription.
And regarding the setting, I add encoding="opus" and it works. I am not quite sure how to find the sample_rate, but it seems that I leave it empty it works fine. It doesn't work with 16000 or 4800.
I haven't not sure supabase APIs before, but based on that function, none of our code exists inside get_interview
.
I would first put debug/trace in between those two supabase APIs to see which of those two calls are causing the hang, then I would probably ask someone in the supabase community to see if they have any suggestions.
If you are using containerized audio which you are, then you don't need to specify either of those parameters. Most people use a different encoding (not opus) which is why it struck my eye initially.
send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.keep_alive ENTER Sending KeepAlive... AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE keep_alive succeeded AsyncListenWebSocketClient.keep_alive LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() succeeded AsyncListenWebSocketClient.send LEAVE response_type: Metadata, data: {'type': 'Metadata', 'transaction_key': 'deprecated', 'request_id': 'ef0834ab-b8dc-42b4-a1f0-a965767744cd', 'sha256': '5d44a359a732cbba9b6308d1116e8cc8282237d7de5173ba3c581fac3258a4ad', 'created': '2024-08-22T22:50:09.437Z', 'duration': 0.0, 'channels': 0} MetadataResponse: MetadataResponse(type='Metadata', transaction_key='deprecated', request_id='ef0834ab-b8dc-42b4-a1f0-a965767744cd', sha256='5d44a359a732cbba9b6308d1116e8cc8282237d7de5173ba3c581fac3258a4ad', created='2024-08-22T22:50:09.437Z', duration=0.0, channels=0, models=None, model_info=None, extra=None) AsyncListenWebSocketClient._emit ENTER callback handlers for: Metadata after running thread: MainThread number of active threads: 1 after running thread: MainThread number of active threads: 1 AsyncListenWebSocketClient._emit LEAVE _listening(1000) exiting gracefully AsyncListenWebSocketClient._listening LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.keep_alive ENTER Sending KeepAlive... AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE keep_alive succeeded AsyncListenWebSocketClient.keep_alive LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.send ENTER send() exiting gracefully: 1000 AsyncListenWebSocketClient.send LEAVE AsyncListenWebSocketClient.finish ENTER closing socket...
This is the log I turn on spam log. It seems all the send are not succeed. Is there a way to find out why?
A 1000
error means the websocket is no longer connected anymore. Some thing terminated the connection.
Usually when you get the Metadata message, it means the connection is closed because audio went through to DG ('duration': 0.0
):
Metadata, data: {'type': 'Metadata', 'transaction_key': 'deprecated', 'request_id': 'ef0834ab-b8dc-42b4-a1f0-a965767744cd', 'sha256': '5d44a359a732cbba9b6308d1116e8cc8282237d7de5173ba3c581fac3258a4ad', 'created': '2024-08-22T22:50:09.437Z', 'duration': 0.0, 'channels': 0}
Check the return value here because currently you aren't:
await dg_connection.start(options)
I would also recommend subscribing to the Close
event to see when the connection closes. Usually a 1000
means a graceful connection close. If you didn't trigger the close, then the server did because it received something it didn't expect (example, non-audio bytes or audio of the incorrect encoding).
Dump out the bytes you are calling in send() and verify that it is audio. Another way to achieve this, save the bytes to a file, and you should be able to play that file using VLC.
yeah, I found something funny....
if I enable this interview = await get_interview(interview_id)
, the audio file is broken, but I disable it, it is playable...
Still couldn't understand the connection here, but I think at least it is confirmed that the DG close connection due to the malformed bytes.
Glad you figured it out!
the issue is frontend may send the data without waiting the socket connects. Due to the extra query delay, websocket doesn't not accept the immediately and causes the first few chunks data loss. My understanding is opus encoding should allow some data loss. But not sure if the first chunk matters.
It does matter. The first frame contains the header information for audio. Open the connection first, then send the audio. If you need to buffer and retain the audio frames, you need to need to do that in order for everything to work properly.
If you are looking for help, we have a Discord community of people that very knowledgeable and we also have an AI bot in the #ask-ai channel where you are ask it these questions.
Here is a link to join Discord: https://dpgr.am/discord
What is the current behavior?
I have a fastapi websocket server to listen audio and send via deepgram async socket for the transcription. When I added the supabase client access, it stops return anything from on_message.
When I enable debug, I got flash with
I think it means the connection has been established but not sure if the audio is actually transferred.
Steps to reproduce
Some code snippets:
Expected behavior
expect on_message to return message.
Please tell us about your environment
MacOS 14.5 (23F79) Python3.12 ## Other information