Text-to-speech

Generate and save WAV speech with the synchronous or asynchronous Python client.

Synchronous client

from pathlib import Path
import os
import orbitalsai
 
client = orbitalsai.Client(api_key=os.environ["ORBITALSAI_API_KEY"])
audio = client.synthesize(
    "Sannu, muna maraba da ku.",
    language="Hausa",
)
Path("welcome.wav").write_bytes(audio)

Async client

from pathlib import Path
import asyncio
import os
import orbitalsai
 
async def main():
    async with orbitalsai.AsyncClient(
        api_key=os.environ["ORBITALSAI_API_KEY"]
    ) as client:
        audio = await client.synthesize("Ẹ káàbọ̀", language="Yoruba")
        Path("welcome.wav").write_bytes(audio)
 
asyncio.run(main())

Both methods use Perigee-1-tts and return bytes containing a complete WAV file. The SDK accepts up to 10,000 Unicode characters.

Queued generation

synthesize() uses a background job automatically. Return immediately when needed:

job = client.synthesize("Sannu", language="Hausa", wait=False)
completed = client.wait_for_speech_job(job.job_id)
print(completed.audio_url)

Use get_speech_job(job_id) when your application manages polling itself.

Streaming

with open("speech.wav", "wb") as output:
    for chunk in client.stream_speech("Today’s announcement", language="English"):
        output.write(chunk)

The returned audio is 24 kHz, 16-bit, mono WAV. See the Text-to-speech guide, Voice cloning SDK, and TTS API reference.

On this page