Skip to main content

TranscriptionRequest

Struct TranscriptionRequest 

Source
pub struct TranscriptionRequest {
    pub file: PathBuf,
    pub model: String,
    pub language: Option<String>,
    pub prompt: Option<String>,
    pub response_format: Option<AudioResponseFormat>,
    pub temperature: Option<f32>,
    pub timestamp_granularities: Option<Vec<TimestampGranularity>>,
    pub chunking_strategy: Option<ChunkingStrategy>,
    pub include: Option<Vec<Include>>,
    pub extra_body_map: Option<Map<String, Value>>,
}
Expand description

Transcribes audio into the input language.

The keywords, languages, known_speaker_names, and known_speaker_references parameters are not covered by this type yet.

Fields§

§file: PathBuf

The audio file (as a path) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified; an extension-bearing filename satisfies this.

§model: String

ID of the model to use. The options are gpt-transcribe, gpt-4o-transcribe, gpt-4o-mini-transcribe, whisper-1 (which is powered by the open source Whisper V2 model), and gpt-4o-transcribe-diarize.

§language: Option<String>

The language of the input audio. Supplying the input language in ISO-639-1 (e.g. en) format will improve accuracy and latency.

§prompt: Option<String>

An optional text to guide the model’s style or continue a previous audio segment. The prompt should match the audio language.

§response_format: Option<AudioResponseFormat>

The format of the output, in one of these options: json, text, srt, verbose_json, or vtt. For gpt-4o-transcribe and gpt-4o-mini-transcribe, the only supported format is json.

With json / verbose_json, use get_response; with text / srt / vtt, use get_response_string.

§temperature: Option<f32>

The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

§timestamp_granularities: Option<Vec<TimestampGranularity>>

The timestamp granularities to populate for this transcription. response_format must be set to verbose_json to use timestamp granularities. Either or both of these options are supported: word, or segment.

§chunking_strategy: Option<ChunkingStrategy>

Controls how the audio is cut into chunks.

When set to auto, the server first normalizes loudness and then uses voice activity detection (VAD) to choose boundaries. A server_vad object can be provided to tweak VAD detection parameters manually. If unset, the audio is transcribed as a single block.

§include: Option<Vec<Include>>

Additional information to include in the transcription response. logprobs will return the log probabilities of the tokens in the response.

§extra_body_map: Option<Map<String, Value>>

Additional JSON properties, sent as extra multipart text fields (strings verbatim, other JSON values serialized).

Trait Implementations§

Source§

impl Clone for TranscriptionRequest

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TranscriptionRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TranscriptionRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Post for TranscriptionRequest

Source§

fn build_url(&self, base_url: &str) -> Result<String, OapiError>

Builds the URL for the request.

base_url should be like https://api.openai.com/v1

Source§

fn is_streaming(&self) -> bool

Source§

impl PostNoStream for TranscriptionRequest

Source§

async fn get_response_string( &self, client: &Client, base_url: &str, options: &RequestOptions, ) -> Result<String, OapiError>

Sends a transcription POST request using multipart/form-data format, following the field layout of the official SDK.

Source§

type Response = TranscriptionResponse

Source§

fn get_response( &self, client: &Client, url: &str, options: &RequestOptions, ) -> impl Future<Output = Result<Self::Response, OapiError>> + Send + Sync

Sends a POST request and deserializes the response.
Source§

impl Serialize for TranscriptionRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more