DEV Community

Discussion on: Deepgram x DEV Hackathon Help Thread

Collapse
 
sandy_codes_py profile image
Santhosh (sandy inspires)

@michaeljolley
I'm trying to send real-time audio to deebgram and get the transcription but I get this error while doing so.
I'm using pyaudio to send the binary data.

input_audio = stream_in.read(3200)
await ws.send(input_audio)

DEBUG:websockets.client:< CLOSE 1008 (policy violation) DATA-0000 [11 bytes]

Collapse
 
tonyasims profile image
Tonya Sims

Hi @sandy_codes_py ! Happy Monday! I'm sorry to hear you were having some trouble. Were you able to figure out the issue? Please let me know if you still need some help and we can work through it together.

Collapse
 
sandy_codes_py profile image
Santhosh (sandy inspires)

Nope, I followed your Flask repo and did that same. But I really want to run that in just Python and not on Flask. I do have limited knowledge on asyncio. Will be learning that soon. I've shared the error and the complete code I'm using the same thread.

Thread Thread
 
tonyasims profile image
Tonya Sims • Edited

Ok, so if I understand correctly you follwed the Flask example in the tutorial but still having some issues? Is the issue still with PyAudio?

Also, is this the error message you received? (I want to make sure this is the correct error):

input_audio = stream_in.read(3200)
await ws.send(input_audio)

DEBUG:websockets.client:< CLOSE 1008 (policy violation) DATA-0000 [11 bytes]

Thread Thread
 
sandy_codes_py profile image
Santhosh (sandy inspires) • Edited

Sorry to misled you!
Actually I wanted to directly send the audio feed using PyAudio to the Deepgram websocket (that's when the above error is occurring).
But I found your Flask tutorial and used that instead which worked in the first go.

The complete code I used can be found here.

Thread Thread
 
tonyasims profile image
Tonya Sims

Oh nice! Good to hear you found a solution with the tutorial 😄.

About asyncio, yea, I totally understand it can be very confusing. It took me awhile to wrap my head around it. How do you plan on learning asyncio? Tutorials? Blog posts? Videos? Something else?

Thread Thread
 
sandy_codes_py profile image
Santhosh (sandy inspires)

Gonna read through this for a while and try some hands-on stuff.
docs.python.org/3/library/asyncio....
I'll try to make a tutorial here once I get a good grasp.

Thread Thread
 
tonyasims profile image
Tonya Sims

Wonderful! Make sure to let me know when it's published so I can read it :)

Thread Thread
 
sandy_codes_py profile image
Santhosh (sandy inspires)

You got it!

Collapse
 
michaeljolley profile image
Michael Jolley

Hi @sandy_codes_py, I'm not a Python pro, but I can hook you up with @tonyasims. She's an amazing pythonista and one of Deepgram's Developer Advocates.

One thing that might help, is there a GitHub repo where we can review the full block of code?

Collapse
 
sandy_codes_py profile image
Santhosh (sandy inspires)

Please check here
I've used api reference code from the deepgram docs

Thread Thread
 
michaeljolley profile image
Michael Jolley

Sweet. Thanks for that. Tonya is out of the office today, but she'll likely respond Monday.

Mental note: I should really start playing with Python more so I can help more. 🙂

Thread Thread
 
sandy_codes_py profile image
Santhosh (sandy inspires) • Edited

That would do!
I did find a workaround it by using her post "Live Transcription With Python and Flask" but that's not really needed here.
I just want to run it locally to do something cool.
Yay, even I've to learn about async and how it works.

Thread Thread
 
michaeljolley profile image
Michael Jolley

Great! I think she wrote several posts like that: "using Flask," "using Django," "using FastAPI," and more.

And yeah! for learning! 🎉🎉