@deepgram/sdk 3.4.4 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/lib/constants.d.ts +1 -0
- package/dist/main/lib/constants.d.ts.map +1 -1
- package/dist/main/lib/constants.js +19 -2
- package/dist/main/lib/constants.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +3 -1
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +7 -4
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts +2 -0
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/main/lib/types/SyncPrerecordedResponse.d.ts +2 -0
- package/dist/main/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
- package/dist/main/lib/types/TranscriptionSchema.d.ts +4 -0
- package/dist/main/lib/types/TranscriptionSchema.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/packages/AbstractLiveClient.d.ts.map +1 -1
- package/dist/main/packages/AbstractLiveClient.js +17 -0
- package/dist/main/packages/AbstractLiveClient.js.map +1 -1
- package/dist/main/packages/ListenLiveClient.d.ts +4 -0
- package/dist/main/packages/ListenLiveClient.d.ts.map +1 -1
- package/dist/main/packages/ListenLiveClient.js +8 -0
- package/dist/main/packages/ListenLiveClient.js.map +1 -1
- package/dist/module/lib/constants.d.ts +1 -0
- package/dist/module/lib/constants.d.ts.map +1 -1
- package/dist/module/lib/constants.js +19 -2
- package/dist/module/lib/constants.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +3 -1
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +4 -3
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts +2 -0
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/module/lib/types/SyncPrerecordedResponse.d.ts +2 -0
- package/dist/module/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
- package/dist/module/lib/types/TranscriptionSchema.d.ts +4 -0
- package/dist/module/lib/types/TranscriptionSchema.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/packages/AbstractLiveClient.d.ts.map +1 -1
- package/dist/module/packages/AbstractLiveClient.js +17 -0
- package/dist/module/packages/AbstractLiveClient.js.map +1 -1
- package/dist/module/packages/ListenLiveClient.d.ts +4 -0
- package/dist/module/packages/ListenLiveClient.d.ts.map +1 -1
- package/dist/module/packages/ListenLiveClient.js +8 -0
- package/dist/module/packages/ListenLiveClient.js.map +1 -1
- package/dist/umd/deepgram.js +1 -1
- package/package.json +2 -1
- package/src/lib/constants.ts +19 -4
- package/src/lib/helpers.ts +6 -3
- package/src/lib/types/LiveTranscriptionEvent.ts +2 -0
- package/src/lib/types/SyncPrerecordedResponse.ts +2 -0
- package/src/lib/types/TranscriptionSchema.ts +5 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/AbstractLiveClient.ts +18 -0
- package/src/packages/ListenLiveClient.ts +11 -0
|
@@ -2,6 +2,7 @@ import { AbstractClient, noop } from "./AbstractClient";
|
|
|
2
2
|
import { CONNECTION_STATE, SOCKET_STATES } from "../lib/constants";
|
|
3
3
|
import type { DeepgramClientOptions, LiveSchema } from "../lib/types";
|
|
4
4
|
import type { WebSocket as WSWebSocket } from "ws";
|
|
5
|
+
import { isBun } from "../lib/helpers";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Represents a constructor for a WebSocket-like object that can be used in the application.
|
|
@@ -119,6 +120,23 @@ export abstract class AbstractLiveClient extends AbstractClient {
|
|
|
119
120
|
return;
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
/**
|
|
124
|
+
* @summary Bun websocket transport has a bug where it's native WebSocket implementation messes up the headers
|
|
125
|
+
* @summary This is a workaround to use the WS package for the websocket connection instead of the native Bun WebSocket
|
|
126
|
+
* @summary you can track the issue here
|
|
127
|
+
* @link https://github.com/oven-sh/bun/issues/4529
|
|
128
|
+
*/
|
|
129
|
+
if (isBun()) {
|
|
130
|
+
import("ws").then(({ default: WS }) => {
|
|
131
|
+
this.conn = new WS(requestUrl, {
|
|
132
|
+
headers: this.headers,
|
|
133
|
+
});
|
|
134
|
+
console.log(`Using WS package`);
|
|
135
|
+
this.setupConnection();
|
|
136
|
+
});
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
122
140
|
/**
|
|
123
141
|
* Native websocket transport (browser)
|
|
124
142
|
*/
|
|
@@ -111,6 +111,17 @@ export class ListenLiveClient extends AbstractLiveClient {
|
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Sends a "Finalize" message to flush any transcription sitting in the server's buffer.
|
|
116
|
+
*/
|
|
117
|
+
public finalize(): void {
|
|
118
|
+
this.send(
|
|
119
|
+
JSON.stringify({
|
|
120
|
+
type: "Finalize",
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
114
125
|
/**
|
|
115
126
|
* @deprecated Since version 3.4. Will be removed in version 4.0. Use `requestClose` instead.
|
|
116
127
|
*/
|