mistral_common.protocol.transcription.request
TranscriptionRequest(**data)
Bases: BaseCompletionRequest
A class representing a request for audio transcription.
This class handles the conversion of audio data into a format suitable for transcription using the OpenAI API. It includes methods to convert the request to and from the OpenAI format.
Attributes:
Name | Type | Description |
---|---|---|
id |
Optional[str]
|
An optional identifier for the transcription request. |
model |
Optional[str]
|
The model to be used for transcription. |
audio |
RawAudio
|
The audio data to be transcribed. |
language |
Optional[LanguageAlpha2]
|
The language of the input audio in ISO-639-1 format (optional). |
strict_audio_validation |
bool
|
A flag indicating whether to perform strict validation of the audio data. |
Source code in .venv/lib/python3.13/site-packages/pydantic/main.py
from_openai(openai_request, strict=False)
classmethod
Create a TranscriptionRequest instance from an OpenAI request dictionary.
This method converts an OpenAI request dictionary into a TranscriptionRequest instance, handling the conversion of audio data and other parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
openai_request
|
Dict[str, Any]
|
The OpenAI request dictionary. |
required |
strict
|
bool
|
A flag indicating whether to perform strict validation of the audio data. |
False
|
Returns:
Type | Description |
---|---|
TranscriptionRequest
|
An instance of TranscriptionRequest. |
Source code in src/mistral_common/protocol/transcription/request.py
to_openai(exclude=(), **kwargs)
Convert the transcription request into the OpenAI format.
This method prepares the transcription request data for compatibility with the OpenAI API. It handles the conversion of audio data and additional parameters into the required format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exclude
|
tuple
|
Fields to exclude from the conversion. |
()
|
kwargs
|
Any
|
Additional parameters to be added to the request. |
{}
|
Returns:
Type | Description |
---|---|
Dict[str, List[Dict[str, Any]]]
|
The request in the OpenAI format. |
Raises:
Type | Description |
---|---|
ImportError
|
If the required soundfile library is not installed. |