Soniox

Examples

Step-by-step descriptions of each Python SDK code example.

Each script under examples/ is a runnable story that proves a key surface of the SDK. Use the links below to open the exact file on GitHub, then run it with a Soniox API key.

Soniox client REST example

examples/soniox_client/api_example.py

  • Uploads assets/coffee_shop.mp3 via client.files.upload and records the returned file ID.
  • Creates a transcription job, polls it to completion with transcriptions.wait, and prints a transcript snippet.
  • Handles SonioxAPIError/SonioxNotFoundError, then deletes both the transcription and uploaded file so you can rerun the example safely.

Sonoix client realtime example

examples/soniox_client/realtime_example.py

  • Builds RealtimeSTTConfig, opens client.realtime.stt.connect, and streams throttled chunks from assets/coffee_shop.mp3.
  • Collects RealtimeEvent.tokens, splits them into final/non-final buckets, and renders a live transcript view with render_tokens.
  • Prints the cached session.last_message after the session closes to show how to inspect the final event.

Async Soniox client REST example

examples/async_soniox_client/api_example.py

  • Mirrors the sync REST demo but uses AsyncSonioxClient, await semantics, and async cleanup in the finally block.
  • Demonstrates how to list files, trigger a transcription, poll via await client.transcriptions.wait, and fetch the transcript without blocking the event loop.
  • Prints structured API error details if something fails so you can wire the same handling into your async app.

Async Soniox client realtime example

examples/async_soniox_client/realtime_example.py

  • Opens an async realtime session, streams throttle_audio_async, and sends control messages implicitly via send_bytes.
  • Iterates async for event in session.receive_events() so tokens arrive as they are produced.
  • Uses render_tokens to show speaker-aware snippets, then prints session.last_message after the async with block.

Each example writes to stdout so you can follow the story while the script runs.