Skip to content

Commit

Permalink
feat: add speechstarted event to sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeocodes committed Jan 24, 2024
1 parent 7c41660 commit 0ff55dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/enums/LiveTranscriptionEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export enum LiveTranscriptionEvents {
Metadata = "Metadata", // exact match to data type from API
Error = "error",
Warning = "warning",
SpeechStarted = "SpeechStarted",
}
5 changes: 5 additions & 0 deletions src/lib/types/SpeechStartedEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface SpeechStartedEvent {
type: "SpeechStarted";
channel: number[];
timestamp: number;
}
1 change: 1 addition & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type { LiveTranscriptionEvent } from "./LiveTranscriptionEvent";
export type { MessageResponse } from "./MessageResponse";
export type { FileSource, PrerecordedSource, UrlSource } from "./PrerecordedSource";
export type { SendProjectInviteSchema } from "./SendProjectInviteSchema";
export type { SpeechStartedEvent } from "./SpeechStartedEvent";
export type { SyncPrerecordedResponse } from "./SyncPrerecordedResponse";
export type { TranscriptionSchema, PrerecordedSchema, LiveSchema } from "./TranscriptionSchema";
export type { UpdateProjectMemberScopeSchema } from "./UpdateProjectMemberScopeSchema";
Expand Down
5 changes: 5 additions & 0 deletions src/packages/LiveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
LiveMetadataEvent,
LiveTranscriptionEvent,
DeepgramClientOptions,
SpeechStartedEvent,
} from "../lib/types";

export class LiveClient extends AbstractWsClient {
Expand Down Expand Up @@ -53,6 +54,10 @@ export class LiveClient extends AbstractWsClient {
if (data.type === LiveTranscriptionEvents.Transcript) {
this.emit(LiveTranscriptionEvents.Transcript, data as LiveTranscriptionEvent);
}

if (data.type === LiveTranscriptionEvents.SpeechStarted) {
this.emit(LiveTranscriptionEvents.SpeechStarted, data as SpeechStartedEvent);
}
} catch (error) {
this.emit(LiveTranscriptionEvents.Error, {
event,
Expand Down

0 comments on commit 0ff55dd

Please sign in to comment.