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)
python test_orpheus_connect_by_voice.py \
  --provider PROVIDER_NAME \
  --voice josh \
  --api-key YOUR_API_KEY

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.5.tar.gz (1.4 MB 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.5-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.5.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • 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.5.tar.gz
Algorithm Hash digest
SHA256 eca28e4091c4d958c0c2218079e5a3e1e3a30e12fff214448e5205c13600ea83
MD5 f857773ca805d17d47a95935d80f840b
BLAKE2b-256 aa5a1db7b6da00dad527bcb83bf5c2a75f2aa76bdbdbea849ddfdc34f75c4b60

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ff0dbcc386b37439df91622d46496b8c8d219c7b53a485a7ba45a02b47166fdc
MD5 cd5fcfcb85185a2c84323198266a991f
BLAKE2b-256 94117638d4908c099503c620c205c6d0cd9286d03f3776f23e77fd60c2b3167e

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