deepgram / deepgram-js-sdk

Official JavaScript SDK for Deepgram's automated speech recognition APIs.
https://developers.deepgram.com
MIT License
127 stars 45 forks source link

ReferenceError: Blob is not defined #258

Closed RiccardoRomagnoli closed 3 months ago

RiccardoRomagnoli commented 3 months ago

What is the current behavior?

What's happening that seems wrong?

When doing LiveClient.send I get this stack trace:

(node:2656) UnhandledPromiseRejectionWarning: ReferenceError: Blob is not defined at LiveClient.send (/voicemail/node_modules/@deepgram/sdk/dist/main/packages/LiveClient.js:81:38) at WebSocket. (file:///voicemail/server.js:87:30) at WebSocket.emit (events.js:314:20) at Receiver.receiverOnMessage (/voicemail/node_modules/ws/lib/websocket.js:1209:20) at Receiver.emit (events.js:314:20) at /voicemail/node_modules/ws/lib/receiver.js:608:16 at internal/process/task_queues.js:153:7 at AsyncResource.runInAsyncScope (async_hooks.js:189:9) at AsyncResource.runMicrotask (internal/process/task_queues.js:150:8) at processTicksAndRejections (internal/process/task_queues.js:97:5)

We want to make sure the problem isn't specific to your operating system or programming language.

Other information

My code: deepgramConnection.send(Buffer.from(msg.media.payload, 'base64'));

Fix

I think just importing Blob should be enough since Node.js 16

lukeocodes commented 3 months ago

I believe Blob came at a later version?

RiccardoRomagnoli commented 3 months ago

https://nodejs.org/docs/latest-v16.x/api/buffer.html#class-blob

I don't see why anyone else still did not encounter this issue with nodejs. I will switch to direct ws connection

lukeocodes commented 3 months ago

Thanks. Off the top of my head, I cannot remember the difference between Blob on 16 Vs 18, but you are not the first person to raise it.

Regardless, the package is pinned at Node 18 because of it

RiccardoRomagnoli commented 3 months ago

I'm using node 18

On Sun, 24 Mar 2024, 23:04 Luke Oliff, @.***> wrote:

Thanks. Off the top of my head, I cannot remember the difference between Blob on 16 Vs 18, but you are not the first person to raise it.

Regardless, the package is pinned at Node 18 because of it

— Reply to this email directly, view it on GitHub https://github.com/deepgram/deepgram-js-sdk/issues/258#issuecomment-2016959829, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMCQVTVYQS3TWYQZ65CZGCLYZ5EVNAVCNFSM6AAAAABFFXOS6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJWHE2TSOBSHE . You are receiving this because you authored the thread.Message ID: @.***>