Skip to content

Latest commit

 

History

History
274 lines (181 loc) · 17.5 KB

File metadata and controls

274 lines (181 loc) · 17.5 KB

Audio.Voices

Overview

Available Operations

list

List all voices (excluding sample data)

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.audio.voices.list(limit=10, offset=0, type_="all")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
limit Optional[int] Maximum number of voices to return
offset Optional[int] Offset for pagination
type Optional[models.ListVoicesV1AudioVoicesGetType] Filter the voices between customs and presets
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VoiceListResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

create

Create a new voice with a base64-encoded audio sample

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.audio.voices.create(name="<value>", sample_audio="<value>", retention_notice=30)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
name str ✔️ N/A
sample_audio str ✔️ Base64-encoded audio file
slug OptionalNullable[str] N/A
languages List[str] N/A
gender OptionalNullable[str] N/A
age OptionalNullable[int] N/A
tags List[str] N/A
color OptionalNullable[str] N/A
retention_notice Optional[int] N/A
sample_filename OptionalNullable[str] Original filename for extension detection
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VoiceResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

delete

Delete a custom voice

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.audio.voices.delete(voice_id="f42bf0d7-8a10-4b98-bbfa-589a232209d2")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
voice_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VoiceResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

update

Update voice metadata (name, gender, languages, age, tags).

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.audio.voices.update(voice_id="030a6b20-e287-414d-9a77-6b76a4a56c9d")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
voice_id str ✔️ N/A
name OptionalNullable[str] N/A
languages List[str] N/A
gender OptionalNullable[str] N/A
age OptionalNullable[int] N/A
tags List[str] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VoiceResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get

Get voice details (excluding sample)

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.audio.voices.get(voice_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
voice_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.VoiceResponse

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*

get_sample_audio

Get the audio sample for a voice

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.audio.voices.get_sample_audio(voice_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
voice_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

str

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.SDKError 4XX, 5XX */*