Skip to content

deepgram.transcription.live has a difficult to use return type #139

@bensalilijames

Description

@bensalilijames

What is the current behavior?

deepgram.transcription.live returns a LiveTranscription | ErrorResponse, which makes it a bit unergonomic to use in TypeScript, because you have to explicitly cast the result to LiveTranscription:

const transcriber = deepgram.transcription.live({
  model: "nova",
  // other options...
}) as LiveTranscription;

Since it can never be ErrorResponse (see implementation here, which can only return a new instance of LiveTranscription) would you consider reverting this change to how it was pre 2.0.0, where it just returns LiveTranscription?

If it's important to keep ErrorResponse, would you be able to suggest a way to safely use the return value, e.g. exporting LiveTranscription and ErrorResponse from this package, and thereby adding support for:

if (transcriber instanceof LiveTranscription) {
  // happy
} else if (transcriber instanceof ErrorResponse) {
  // not happy
}

Thank you! 😃

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions