Skip to main content

Python SDK for Orpheus TTS - stream high-quality speech

Project description

Orpheus TTS Python SDK

Stream high-quality speech from the Orpheus TTS model.

Installation

pip install orpheus-tts

Quick Start

from orpheus_tts import OrpheusClient

client = OrpheusClient(api_key="YOUR_API_KEY", provider="PROVIDER_NAME")

# Stream audio chunks
for chunk in client.stream("Hello world!", voice="josh"):
    # chunk is raw PCM bytes (int16, 48kHz, mono)
    print("Received chunk of length:", len(chunk))

Usage

Pre-connect and Save WAV

import time
import wave

from orpheus_tts import OrpheusClient

API_KEY = "YOUR_API_KEY"
PROVIDER = "PROVIDER_NAME"
VOICE = "josh"
TEXT = "Hello from Orpheus."
OUTPUT = "output.wav"

client = OrpheusClient(api_key=API_KEY, provider=PROVIDER)
client.connect(voice=VOICE, websocket_count=1)
time.sleep(1) # Brief pause to ensure connection is stable

chunks = []
start = time.perf_counter()

for i, chunk in enumerate(client.stream(TEXT, voice=VOICE)):
    if i == 0:
        print(f"TTFA: {(time.perf_counter() - start) * 1000:.1f}ms")
    chunks.append(chunk)

client.close()
audio = b"".join(chunks)

with wave.open(OUTPUT, "wb") as wav:
    wav.setnchannels(1)
    wav.setsampwidth(2)
    wav.setframerate(48000)
    wav.writeframes(audio)

Configuration

client = OrpheusClient(
    api_key="YOUR_API_KEY",
    provider="PROVIDER_NAME",
    max_tokens=3000,        # Maximum tokens to generate
    temperature=1.0,        # Sampling temperature
    repetition_penalty=1.1, # Repetition penalty
)

# Or override per-request
for chunk in client.stream(
    "Custom settings for this request.",
    voice="josh",
    max_tokens=2000,
    temperature=0.9,
):
    process(chunk)

Audio Format

All audio is returned as raw PCM with the following format:

  • Sample Rate: 48,000 Hz
  • Bit Depth: 16-bit signed integer (int16)
  • Channels: Mono (1 channel)

Error Handling

from orpheus_tts import OrpheusClient, OrpheusError, AuthenticationError

client = OrpheusClient(api_key="YOUR_API_KEY", provider="PROVIDER_NAME")

try:
    for chunk in client.stream("Hello!", voice="josh"):
        process(chunk)
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except OrpheusError as e:
    print(f"TTS error: {e}")

Connect with environment variables

export ORPHEUS_TTS_API_KEY="YOUR_API_KEY"
from orpheus_tts import OrpheusClient

client = OrpheusClient(provider="PROVIDER_NAME")  # Reads ORPHEUS_TTS_API_KEY if set
client.connect(websocket_count=1)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

orpheus_tts-0.1.6.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

orpheus_tts-0.1.6-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file orpheus_tts-0.1.6.tar.gz.

File metadata

  • Download URL: orpheus_tts-0.1.6.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for orpheus_tts-0.1.6.tar.gz
Algorithm Hash digest
SHA256 7e58a61aeb625c6372a079d3f3d1e8d4f7ded8717e9f4e46793ca46657f48ec6
MD5 bfe9e29000debd4b316fbca0831499f9
BLAKE2b-256 71f12b6d13f23383a0176c3bce285b6a4a7154b03a33640f5b0432828007125d

See more details on using hashes here.

File details

Details for the file orpheus_tts-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: orpheus_tts-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for orpheus_tts-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7d2d790aad91b26991bb3e2ba460dad2ad609d2edfb418102364eeda3b4085cc
MD5 a16cb44a00073133e275b71b74f265aa
BLAKE2b-256 61fdb9aca0cae12728672154516f3566927c73cdbc617042179168c907901ff0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page