Voice Service#

class saia_python.voice.VoiceService(session: requests.Session, base_url: str, *, retry: RetryPolicy | bool | None = None)[source]#

Access the /audio/transcriptions and /audio/translations endpoints.

Parameters:
  • session – A requests.Session with auth headers configured.

  • base_url – The SAIA API base URL.

transcribe(file_path: str | Path, *, model: str = 'whisper-large-v2', response_format: str = 'text', language: str | None = None, wait: bool = True, retry: RetryPolicy | bool | None = None) str | Future[str][source]#

Transcribe an audio file to text.

Parameters:
  • file_path – Path to the audio file (WAV, MP3, MP4, FLAC).

  • model – Whisper model to use.

  • response_format – Output format — "text", "vtt", or "srt".

  • language – Optional language hint (e.g. "de", "en").

  • wait – If True (default), block until the transcription is ready and return it as a string. If False, submit the request on a background thread and return a concurrent.futures.Future immediately so the call does not block. Resolve it with .result() (which re-raises any error), poll with .done(), or attach .add_done_callback(...).

Returns:

The transcription string when wait=True; otherwise a Future that resolves to that string.

Example:

# Blocking
text = client.voice.transcribe("meeting.mp3")

# Non-blocking — kick it off, do other work, collect later
fut = client.voice.transcribe("meeting.mp3", wait=False)
...                       # other work runs while it transcribes
text = fut.result()       # blocks only now, re-raises on error
translate(file_path: str | Path, *, model: str = 'whisper-large-v2', response_format: str = 'text', wait: bool = True, retry: RetryPolicy | bool | None = None) str | Future[str][source]#

Translate an audio file to English text.

Parameters:
  • file_path – Path to the audio file (WAV, MP3, MP4, FLAC).

  • model – Whisper model to use.

  • response_format – Output format — "text", "vtt", or "srt".

  • wait – If True (default), block until the result is ready and return it as a string. If False, submit on a background thread and return a concurrent.futures.Future that resolves to the translation (see transcribe()).

Returns:

The English translation string when wait=True; otherwise a Future that resolves to that string.