generated from deepgram/oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
What is the current behavior?
Client is not able to connect to the flux and returns error
Steps to reproduce
here is my class for flux csr:
const { createClient } = require("@deepgram/sdk");
const { LiveTranscriptionEvents } = require("@deepgram/sdk");
class DeepGramFluxCSR {
constructor(apiKey) {
this.apiKey = apiKey;
this.client = createClient(apiKey);
this.connection = null;
this.onStartTurn = null;
this.onEndTurn = null;
}
setOnStartTurn(callback) {
this.onStartTurn = callback;
}
setOnEndTurn(callback) {
this.onEndTurn = callback;
}
start() {
this.connection = this.client.listen.live({
model: "flux-general-en",
language: "en",
smart_format: true,
interim_results: true,
endpointing: true,
});
this.connection.on(LiveTranscriptionEvents.Open, () => {
console.log("Deepgram Flux connection opened");
});
this.connection.on(LiveTranscriptionEvents.Transcript, (data) => {
if (data.type === "TurnInfo") {
switch (data.event) {
case "StartOfTurn":
if (this.onStartTurn) {
this.onStartTurn();
}
break;
case "EndOfTurn":
if (this.onEndTurn) {
this.onEndTurn();
}
break;
// Optionally handle other events like 'EagerEndOfTurn', 'TurnResumed', 'Update'
}
}
});
this.connection.on(LiveTranscriptionEvents.Close, () => {
console.log("Deepgram Flux connection closed");
});
this.connection.on(LiveTranscriptionEvents.Error, (error) => {
console.error("Deepgram Flux error:", error);
});
}
send(audioBuffer) {
if (this.connection && !this.connection.getReadyState() === 1) {
// OPEN
this.connection.send(audioBuffer);
} else {
console.warn("Connection not open");
}
}
stop() {
if (this.connection) {
this.connection.finish();
this.connection = null;
}
}
}
module.exports = DeepGramFluxCSR;and here is the test code:
const API_KEY = "myyfukkiinngkeeeyyy"; // ← CRITICAL:
const csr = new DeepGramFluxCSR(API_KEY);
csr.setOnStartTurn(() => {
console.log("🔊 Start of turn detected!");
});
csr.setOnEndTurn(() => {
console.log("🛑 End of turn detected!");
});
csr.start();
and here is the error trace:
Deepgram Flux error: {
error: DeepgramWebSocketError: Received network error or non-101 status code.
at ListenLiveClient.createEnhancedError (C:\Users\.....\node_modules\@deepgram\sdk\dist\main\packages\AbstractLiveClient.js:357:31)
at conn.onerror ...
__dgError: true,
originalEvent: ErrorEvent {
type: 'error',
defaultPrevented: false,
cancelable: false,
timeStamp: 1230.7981
},
statusCode: undefined,
requestId: undefined,
responseHeaders: undefined,
url: 'wss://api.deepgram.com/v1/listen?model=flux-general-en&language=en&smart_format=true&interim_results=true&endpointing=true',
readyState: 0
},
statusCode: undefined,
requestId: undefined,
responseHeaders: undefined,
url: 'wss://api.deepgram.com/v1/listen?model=flux-general-en&language=en&smart_format=true&interim_results=true&endpointing=true',
readyState: 0,
message: 'Received network error or non-101 status code. (Ready State: CONNECTING, URL: wss://api.deepgram.com/v1/listen?model=flux-general-en&language=en&smart_format=true&interim_results=true&endpointing=true)',
[Symbol(type)]: 'error',
[Symbol(kTarget)]: WebSocket {},
[Symbol(kIsBeingDispatched)]: true
}
:microphone: Starting microphone capture... Speak into the mic and watch for turn events.
Press Ctrl+C to stop early.
:wave: Shutting down...luebken
Metadata
Metadata
Assignees
Labels
No labels