mistral_common.protocol.speech.request
SpeechRequest(**data)
Bases: BaseCompletionRequest
Request for text-to-speech synthesis.
Supports both preset voices and voice cloning via reference audio.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str | None
|
Optional unique identifier for the speech request. |
model |
str | None
|
Optional model identifier for the speech synthesis. |
input |
str
|
Text input to be converted to speech. |
voice |
str | None
|
Optional preset voice identifier (e.g., 'Neutral Male', 'Neutral Female') to use for speech synthesis. |
ref_audio |
str | bytes | None
|
Optional reference audio for voice cloning, provided as a base64-encoded string or raw bytes. Takes precedence over voice when both are provided. |
Source code in .venv/lib/python3.14/site-packages/pydantic/main.py
from_openai(openai_request, strict=False)
classmethod
Create a SpeechRequest instance from an OpenAI-compatible request dictionary.
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 |
|---|---|
SpeechRequest
|
An instance of SpeechRequest. |
Source code in src/mistral_common/protocol/speech/request.py
to_openai(**kwargs)
Convert this SpeechRequest to an OpenAI-compatible request dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Additional key-value pairs to include in the request dictionary. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
An OpenAI-compatible request dictionary. |