# packages/client-runtime/src/voice-input/transcription.ts · screen/t3code-personal

[View on GitCafe](https://git.cafe/screen/t3code-personal/blob/eeea71a88108c375c04853f58c298a518a54acaf/packages/client-runtime/src/voice-input/transcription.ts)

Repository: [screen/t3code-personal](https://git.cafe/screen/t3code-personal)

Visibility: public

Requested revision: eeea71a88108c375c04853f58c298a518a54acaf

Requested commit: eeea71a88108c375c04853f58c298a518a54acaf

Commit: eeea71a88108c375c04853f58c298a518a54acaf

Blob: f3ce377acb5f934dc5e15724034235bc052c67ff

Size: 1189 bytes

[Immutable source](https://git.cafe/screen/t3code-personal/blob/eeea71a88108c375c04853f58c298a518a54acaf/packages/client-runtime/src/voice-input/transcription.ts?format=markdown)

```
/** Cancellation is cooperative: settle only after the underlying work has stopped. */
export type VoiceTranscriptionOptions = {
  readonly signal: AbortSignal;
};

/** Binds a recording to its selected implementation and resolved locale. */
export type PreparedVoiceTranscription = {
  readonly locale: string;
  readonly transcribe: (uri: string, options: VoiceTranscriptionOptions) => Promise<string>;
};

export type VoiceTranscriber = {
  readonly prepare: (options: VoiceTranscriptionOptions) => Promise<PreparedVoiceTranscription>;
};

export type VoiceTranscriptionErrorCode =
  | "unavailable"
  | "unsupported-locale"
  | "preparation-failed"
  | "transcription-failed"
  | "cancelled";

export class VoiceTranscriptionError extends Error {
  readonly code: VoiceTranscriptionErrorCode;

  constructor(code: VoiceTranscriptionErrorCode, message: string, options?: ErrorOptions) {
    super(message, options);
    this.name = "VoiceTranscriptionError";
    this.code = code;
  }
}

export function throwIfVoiceTranscriptionAborted(signal: AbortSignal): void {
  if (signal.aborted) {
    throw new VoiceTranscriptionError("cancelled", "Voice transcription was cancelled.");
  }
}

```
