#node sdk error

1 messages · Page 1 of 1 (latest)

little hollow
#

Hello,

I'm trying to use the node sdk but it seems there is an error for live transcripts. Here is what I got :
Error: Unexpected server response: 400
at <anonymous> (/home/tony/workspace/translia-bubble-bac-a-sable/node_modules/@deepgram/sdk/dist/index.js:0:84350)
at <anonymous> (native)
at promiseReactionJob (native)
at processTicksAndRejections (native)

Here is my code

import { fstat } from "fs";

const { Deepgram } = require("@deepgram/sdk");
const express = require('express');
const http = require('http');
const socketIo = require('socket.io');
const fs = require('fs');
const app = express();
const server = http.createServer(app);
const io = socketIo(server);
const deepgramApiKey = "ofcoursenotshown";
const deepgram = new Deepgram(deepgramApiKey);
io.on('connection', (socket) => {
  console.log('New client connected');

  const deepgramLive = deepgram.transcription.live({
    punctuate: true,
  });

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

  deepgramLive.addListener("open", () => {
    socket.emit("can-open-mic")
  });

  deepgramLive.addListener("error", (e) => {
    fs.writeFileSync('logs-error.json', JSON.stringify(e))
  })

  deepgramLive.addListener("transcriptReceived", (message) => {
    const data = JSON.parse(message);
    socket.emit('transcription', data.channel.alternatives[0].transcript);
  });

  socket.on('audio_data', (audioData) => {
    if (deepgramLive.getReadyState() == 1) {
      deepgramLive.send(audioData.read());
    }
  });
  socket.on('disconnect', () => {
    deepgramLive.finish();
  });
});
server.listen(4001);
worthy crag
#

sometimes the response from the server doesn't include transcript, it is metadata only. the server will also close if you send an empty byte, or if you don't send any bytes in around 10s

#

if you have a request ID, i can see what our logs said on our end

little hollow
#

The error seems to happen just after the connection


  const deepgram = new Deepgram(DG_KEY);

  const dgSocket = deepgram.transcription.live({
    punctuate: true
  });
  console.log(dgSocket)
#

Just this code seems to raise an error

worthy crag
#

Immediately?

little hollow
#

yes

worthy crag
#

Is it possible you're sending something to it on connection?

little hollow
#

How ?

worthy crag
#

Hmmm 🤔

#

I had some weird issues when I wrote the JS example we have

#

I think it was to do with too many connections

#

Are you getting a request_id back with the error?

little hollow
#

No the only error is : error: Unexpected server response: 400

worthy crag
#

Can you give me your project UUID?

little hollow
#

Yes : maybe in direct msg

#

Uh

worthy crag
#

here is fine, no one can use it 🙂 it isn't a secret ID, just unique

little hollow
#

ok 7dc7b70c-d5da-4ea6-9e6d-6e945036ec79

worthy crag
#

🙂

#

Someone will have to look into this and they're mostly US East and West coast. So it may be a few hours before I have any suggestions for youi

little hollow
#

Ok thank you for the support

worthy crag
#

Hi @little hollow we took a look at your project ID.

We've seen a few errors in the logs from the same project. They all say this...

    "response": {
      "message": "Bad Request: failed to process audio: corrupt or unsupported data",
      "code": 400,
      "completed": "2023-09-20T11:41:18.114294Z"
    },

Can I confirm what Browser you're using to capture audio?

little hollow
#

Opera

worthy crag
#

Interesting. Have you tried using the other feature flags to set the encoding/sample rate/etc? It might be that we're unable to assume that from the format that Opera is providing

little hollow
#

I switched to a python server it works well. Sorry for the issue
The live streaming does auto detection of language ?