Skip to content

Commit 1f80bab

Browse files
authored
feat: add speechstarted event to sdk (#235)
1 parent 1add378 commit 1f80bab

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/lib/enums/LiveTranscriptionEvents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ export enum LiveTranscriptionEvents {
66
Error = "error",
77
Warning = "warning",
88
UtteranceEnd = "UtteranceEnd", // exact match to data type from API
9+
SpeechStarted = "SpeechStarted",
910
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface SpeechStartedEvent {
2+
type: "SpeechStarted";
3+
channel: number[];
4+
timestamp: number;
5+
}

src/lib/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export type {
4242
AnalyzeSource,
4343
} from "./DeepgramSource";
4444
export type { SendProjectInviteSchema } from "./SendProjectInviteSchema";
45+
export type { SpeechStartedEvent } from "./SpeechStartedEvent";
4546
export type { SyncPrerecordedResponse } from "./SyncPrerecordedResponse";
4647
export type { SyncAnalyzeResponse } from "./SyncAnalyzeResponse";
4748
export type { TranscriptionSchema, PrerecordedSchema, LiveSchema } from "./TranscriptionSchema";

src/packages/LiveClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
LiveTranscriptionEvent,
1313
DeepgramClientOptions,
1414
UtteranceEndEvent,
15+
SpeechStartedEvent,
1516
} from "../lib/types";
1617

1718
export class LiveClient extends AbstractWsClient {
@@ -58,6 +59,10 @@ export class LiveClient extends AbstractWsClient {
5859
if (data.type === LiveTranscriptionEvents.UtteranceEnd) {
5960
this.emit(LiveTranscriptionEvents.UtteranceEnd, data as UtteranceEndEvent);
6061
}
62+
63+
if (data.type === LiveTranscriptionEvents.SpeechStarted) {
64+
this.emit(LiveTranscriptionEvents.SpeechStarted, data as SpeechStartedEvent);
65+
}
6166
} catch (error) {
6267
this.emit(LiveTranscriptionEvents.Error, {
6368
event,

0 commit comments

Comments
 (0)