Voice Service#
- class saia_python.voice.VoiceService(session: requests.Session, base_url: str, *, retry: RetryPolicy | bool | None = None)[source]#
Access the
/audio/transcriptionsand/audio/translationsendpoints.- Parameters:
session – A
requests.Sessionwith 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. IfFalse, submit the request on a background thread and return aconcurrent.futures.Futureimmediately 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 aFuturethat 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. IfFalse, submit on a background thread and return aconcurrent.futures.Futurethat resolves to the translation (seetranscribe()).
- Returns:
The English translation string when
wait=True; otherwise aFuturethat resolves to that string.