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

TypeError: Cannot read properties of undefined (reading 'live') #209

Closed universeroc closed 6 months ago

universeroc commented 7 months ago

What is the current behavior?

const deepgramLive = deepgram.transcription.live({
                                            ^
TypeError: Cannot read properties of undefined (reading 'live')

What's happening that seems wrong?

Steps to reproduce

  1. npm init
  2. npm install cross-fetch @deepgram/sdk
  3. copy code from https://console.deepgram.com/project/0a08e98a-97d1-420f-a11f-6b689b5e5af2/mission/realtime-via-sdk
    
    const fetch = require('cross-fetch');
    const { Deepgram } = require('@deepgram/sdk');

// The API key you created in step 1 const deepgramApiKey = '9b4e81ad9df9966d02246ccc07612405240467a1';

// URL for the real-time streaming audio you would like to transcribe const url = 'http://stream.live.vc.bbcmedia.co.uk/bbc_world_service';

// Initialize the Deepgram SDK const deepgram = new Deepgram(deepgramApiKey);

// Create a websocket connection to Deepgram const deepgramLive = deepgram.transcription.live({ smart_format: true, model: 'nova-2', language: 'en-US' });

// Listen for the connection to open and send streaming audio from the URL to Deepgram fetch(url).then(r => r.body).then(res => { res.on('readable', () => { if(deepgramLive.getReadyState() === 1) { deepgramLive.send(res.read()); } }); });

// Listen for the connection to close deepgramLive.addListener('close', () => { console.log('Connection closed.') });

// Listen for any transcripts received from Deepgram and write them to the console deepgramLive.addListener('transcriptReceived', (transcription) => { console.dir(transcription, { depth: null }); });


4. node index.js

> To make it faster to diagnose the root problem. Tell us how can we reproduce the bug.

## Expected behavior

> What would you expect to happen when following the steps above?

## Please tell us about your environment

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

- **Operating System/Version:** Windows 10
- **Language:** [all | TypeScript | Python | PHP | etc]
- **Browser:** Chrome

## Other information
node version v16.0.0
node version v18.16.0
macOS 14.1.1 (23B81)

> Anything else we should know? (e.g. detailed explanation, stack-traces, related issues, suggestions how to fix, links for us to have context, eg. stack overflow, codepen, etc)
lukeocodes commented 7 months ago

Hi, can you check your package.json for the version of the SDK you are using?

universeroc commented 7 months ago

Hi, can you check your package.json for the version of the SDK you are using?

{
"name": "demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.mjs",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@deepgram/sdk": "^3.0.0",
"cross-fetch": "^4.0.0"
}
}
lukeocodes commented 7 months ago

I imagine you were looking at a guide that uses our V2 SDK, and are using our V3 SDK which was only released yesterday. There was a moment yesterday where we could not physically update both at the same time, and unfortunately you may have fallen into that gap!

You can either re-check our docs (they're updated now) or take a look at our migration guide.