Soniox
SDKsPython

Sync vs async clients

Choose between SonioxClient and AsyncSonioxClient based on your app.

Soniox Python SDK provides two clients.

  • SonioxClient for synchronous code (scripts, CLIs, simple services)
  • AsyncSonioxClient for asyncio apps (FastAPI, aiohttp, background workers)

The files, stt, tts, models, auth, webhooks, and realtime APIs accept the same parameters and return the same types in both clients.

Speech-to-text examples

Sync client (SonioxClient)

from soniox import SonioxClient

client = SonioxClient()

file = client.files.upload("audio.mp3")
transcription = client.stt.transcribe(
    audio_url="https://soniox.com/media/examples/coffee_shop.mp3"
)

print(file.id, transcription.id)

Async client (AsyncSonioxClient)

import asyncio
from soniox import AsyncSonioxClient

async def main():
    client = AsyncSonioxClient()

    file = await client.files.upload("audio.mp3")
    transcription = await client.stt.transcribe(
        audio_url="https://soniox.com/media/examples/coffee_shop.mp3"
    )

    print(file.id, transcription.id)

    await client.aclose()

asyncio.run(main())

Text-to-speech examples

Sync client (SonioxClient)

from soniox import SonioxClient

client = SonioxClient()

written = client.tts.generate_to_file(
    "./audio.wav",
    text="Hello from Soniox!",
    voice="Maya",
)

print(f"Wrote {written} bytes.")

Async client (AsyncSonioxClient)

import asyncio
from soniox import AsyncSonioxClient

async def main() -> None:
    client = AsyncSonioxClient()

    written = await client.tts.generate_to_file(
        "./audio.wav",
        text="Hello from Soniox!",
        voice="Maya",
    )

    print(f"Wrote {written} bytes.")

    await client.aclose()


asyncio.run(main())