Simple fix: add LiveTranscriptionEvents enum
Closed this issue · 3 comments
tieje3 commented
Proposed changes
Current code:
export interface LiveTranscriptionEvent {
type: "Results";
channel_index: number[];
duration: number;
start: number;
// ... etc.
};
}
import { LiveTranscriptionEvents } from "../enums";
export interface LiveTranscriptionEvent {
type: LiveTranscriptionEvents;
channel_index: number[];
duration: number;
start: number;
// ... etc.
};
}
Context
Desired for ease of use.
I understand that this is here because it depends on the type of connection that you're listening to:
connection.addListener(LiveTranscriptionEvents.Transcript, onTranscript);
connection.addListener(LiveTranscriptionEvents.UtteranceEnd, onTranscript);
The workaround for now is to add a @ts-ignore
pragma:
const onUtteranceEnd = (data: LiveTranscriptionEvent) => {
const { type } = data;
// @ts-ignore
if (type === LiveTranscriptionEvents.UtteranceEnd) {
tieje3 commented
I guess you don't really need it because you'll only ever receive the event and not much more info than that.
lukeocodes commented
I think you'd get a TS error if you data never matched the event coming through?
tieje3 commented
Thanks for the quick response. I realized that I was just being dumb and I closed the ticket. 😊 You may wish to review the ticket for future updates though.
From: Luke Oliff ***@***.***>
Sent: Tuesday, May 28, 2024 11:49 AM
To: deepgram/deepgram-js-sdk ***@***.***>
Cc: Francis, Thomas James ***@***.***>; State change ***@***.***>
Subject: Re: [deepgram/deepgram-js-sdk] Simple fix: add LiveTranscriptionEvents enum (Issue #298)
I think you'd get a TS error if you data never matched the event coming through?
—
Reply to this email directly, view it on GitHub<#298 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BIFMW5BO5ZCEUU22HLIBG23ZESRPZAVCNFSM6AAAAABINDABGCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZVGU4DKNBYGM>.
You are receiving this because you modified the open/close state.Message ID: ***@***.***>