Skip to content

Latest commit

 

History

History
108 lines (74 loc) · 10.2 KB

File metadata and controls

108 lines (74 loc) · 10.2 KB

Audio.Transcriptions

Overview

API for audio transcription.

Available Operations

  • complete - Create Transcription
  • stream - Create Streaming Transcription (SSE)

complete

Create Transcription

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.audio.transcriptions.complete(model="voxtral-mini-latest", diarize=False)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
model str ✔️ ID of the model to be used. Example 1: voxtral-mini-latest
Example 2: voxtral-mini-2507
file Optional[models.File] N/A
file_url OptionalNullable[str] Url of a file to be transcribed
file_id OptionalNullable[str] ID of a file uploaded to /v1/files
language OptionalNullable[str] Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
temperature OptionalNullable[float] N/A
diarize Optional[bool] N/A
context_bias List[str] N/A
timestamp_granularities List[models.TimestampGranularity] Granularities of timestamps to include in the response.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.TranscriptionResponse

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

stream

Create Streaming Transcription (SSE)

Example Usage

from mistralai.client import Mistral
import os


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

    res = mistral.audio.transcriptions.stream(model="Camry", diarize=False)

    with res as event_stream:
        for event in event_stream:
            # handle event
            print(event, flush=True)

Parameters

Parameter Type Required Description
model str ✔️ N/A
file Optional[models.File] N/A
file_url OptionalNullable[str] Url of a file to be transcribed
file_id OptionalNullable[str] ID of a file uploaded to /v1/files
language OptionalNullable[str] Language of the audio, e.g. 'en'. Providing the language can boost accuracy.
temperature OptionalNullable[float] N/A
diarize Optional[bool] N/A
context_bias List[str] N/A
timestamp_granularities List[models.TimestampGranularity] Granularities of timestamps to include in the response.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

Union[eventstreaming.EventStream[models.TranscriptionStreamEvents], eventstreaming.EventStreamAsync[models.TranscriptionStreamEvents]]

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*