OpenAiTranscriptionModel unstable
OpenAI implementation of TranscriptionModel.
Recordings go to the transcriptions endpoint. Live audio goes to a Realtime
transcription session over a WebSocket, which the layerRealtime and
modelRealtime constructors add. Live transcription supports only models
with server-side turn detection.
Configuration
withConfigOverride
unstableProvides config overrides for OpenAI transcription model operations.
Signature
declare const withConfigOverride: { (overrides: { readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Duration.Input; readonly include?: typeof OpenAiSchema.RealtimeTranscriptionSession.Encoded["include"]; readonly noise_reduction?: RealtimeInput["noise_reduction"]; readonly turn_detection?: RealtimeInput["turn_detection"]; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">; }): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, Config>>; <A, E, R>(self: Effect<A, E, R>, overrides: { readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Duration.Input; readonly include?: typeof OpenAiSchema.RealtimeTranscriptionSession.Encoded["include"]; readonly noise_reduction?: RealtimeInput["noise_reduction"]; readonly turn_detection?: RealtimeInput["turn_detection"]; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">; }): Effect<A, E, Exclude<R, Config>>;}Constructors
Creates an OpenAI transcription model for recordings. Its transcribeLive
fails with an AiError.
Gotchas
- OpenAI does not fetch audio. A recording given as a URL fails with
AiError.InvalidUserInputError. - OpenAI reads the audio format from the file name. Without
fileName, the name is derived frommediaType.
See
- makeRealtime for a model that also transcribes live audio
Signature
declare const make: (...args: [options: { readonly config?: Omit<{ readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: ... | ...; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: ... | ...; readonly silence_duration_ms?: ... | ...; readonly threshold?: ... | ...; readonly type: "server_vad"; } | { readonly eagerness?: ... | ... | ... | ... | ...; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">; }, "model">; readonly model: string & {} | Model;}]) => Effect<TranscriptionModel, never, OpenAiClient>makeRealtime
unstableCreates an OpenAI transcription model for recordings and live audio.
Details
Each live stream opens its own Realtime transcription session and closes it
when the stream ends. Segments follow OpenAI's server-side turn detection.
Their start and end are the times at which turn detection heard speech
begin and stop.
When audio ends, the session commits the audio that turn detection has
not committed yet. The stream completes once OpenAI has answered that
commit and every turn it announced has a final transcript. If OpenAI
rejects the commit for any reason other than having no audio left to
commit, the stream fails with that error.
Gotchas
- PCM16 audio must be 24 kHz mono. G.711 audio must be 8 kHz mono. Other
formats fail with
AiError.InvalidUserInputError. gpt-live-transcribehas no server-side turn detection and fails withAiError.InvalidUserInputError.- If transcripts are still due
realtime.flushTimeoutafter the audio ended, the stream fails with a retryableAiError, even when the session is still sending. Raise it when much audio is sent at once, as after atranscribeLiveBufferedreplay. - OpenAI does not say which commit a
committedevent answers. When the audio ends during speech, the closing commit counts as answered once a commit has been announced and the clear sent after it is acknowledged. A turn that OpenAI announces only after that is not waited for. - OpenAI does not commit less than 100 ms of audio, so a shorter tail is not transcribed.
See
- layerRealtime for the WebSocket constructors that work
Signature
declare const makeRealtime: (...args: [options: { readonly config?: Omit<{ readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: ... | ...; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: ... | ...; readonly silence_duration_ms?: ... | ...; readonly threshold?: ... | ...; readonly type: "server_vad"; } | { readonly eagerness?: ... | ... | ... | ... | ...; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">; }, "model">; readonly model: string & {} | Model;}]) => Effect<TranscriptionModel, never, OpenAiClient | WebSocketConstructor>Creates an OpenAI model that transcribes recordings.
See
- modelRealtime for a model that also transcribes live audio
Signature
declare function model(model: string & {} | Model, config?: Omit<{ readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: "near_field" | "far_field"; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; } | { readonly eagerness?: "low" | "medium" | "high" | "auto"; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">;}, "model">): Model<"openai", TranscriptionModel, OpenAiClient>modelRealtime
unstableCreates an OpenAI model that transcribes recordings and live audio.
See
- layerRealtime for the WebSocket constructors that work
Signature
declare function modelRealtime(model: string & {} | Model, config?: Omit<{ readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: "near_field" | "far_field"; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; } | { readonly eagerness?: "low" | "medium" | "high" | "auto"; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">;}, "model">): Model<"openai", TranscriptionModel, OpenAiClient | WebSocketConstructor>Layers
Creates a layer for an OpenAI transcription model that handles recordings.
See
- layerRealtime for a layer that also handles live audio
Signature
declare function layer(options: { readonly config?: Omit<{ readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: "near_field" | "far_field"; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; } | { readonly eagerness?: "low" | "medium" | "high" | "auto"; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">; }, "model">; readonly model: string & {} | Model;}): Layer<TranscriptionModel, never, OpenAiClient>layerRealtime
unstableCreates a layer for an OpenAI transcription model that handles recordings and live audio.
Gotchas
The Authorization header is sent through the WebSocket constructor's
non-standard options. Use NodeSocket.layerWebSocketConstructor,
NodeWS.layerWebSocketConstructor, or BunSocket.layerWebSocketConstructor.
Socket.layerWebSocketConstructorGlobal cannot send it.
Signature
declare function layerRealtime(options: { readonly config?: Omit<{ readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: "near_field" | "far_field"; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; } | { readonly eagerness?: "low" | "medium" | "high" | "auto"; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">; }, "model">; readonly model: string & {} | Model;}): Layer<TranscriptionModel, never, OpenAiClient | WebSocketConstructor>Models
Services
Service definition for OpenAI transcription model configuration.
Details
The top-level fields configure requests to the transcriptions endpoint.
language and prompt also apply to live sessions. realtime holds the settings that
only live sessions have. Turn detection defaults to server_vad.
flushTimeout is how long a live session has to deliver the remaining
transcripts once the audio has ended, and defaults to 30 seconds.
Signature
declare class Config extends Shape<"@effect/ai-openai/OpenAiTranscriptionModel/Config", { readonly chunking_strategy?: "auto" | { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; }; readonly include?: readonly Array<"logprobs">; readonly known_speaker_names?: readonly Array<string>; readonly known_speaker_references?: readonly Array<string>; readonly language?: string; readonly model?: string; readonly prompt?: string; readonly realtime?: { readonly flushTimeout?: Input; readonly include?: readonly Array<"item.input_audio_transcription.logprobs">; readonly noise_reduction?: { readonly type: "near_field" | "far_field"; } | null; readonly turn_detection?: { readonly prefix_padding_ms?: number; readonly silence_duration_ms?: number; readonly threshold?: number; readonly type: "server_vad"; } | { readonly eagerness?: "low" | "medium" | "high" | "auto"; readonly type: "semantic_vad"; }; }; readonly response_format?: "json" | "verbose_json" | "diarized_json"; readonly temperature?: number; readonly timestamp_granularities?: readonly Array<"word" | "segment">;}, this> { constructor(_: never);}