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

Uploaded Python 3

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.4.tar.gz
  • Upload date:
  • Size: 1.5 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.4.tar.gz
Algorithm Hash digest
SHA256 88d951448c3ee71f4d0cde0280a006de4528e884f498d1a0c0cdd4076193193c
MD5 ecab6a5dd6b442d03f965ec041a3c566
BLAKE2b-256 a3ef40bd15dd9bca50c273fa72bc6ebb6cfa93518b4b27d95568b4daf6b625d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ffbc769f36d363c94df0e532f001ce6bcafa977762b21ec80218077033256ffd
MD5 f9889b1d7a1de79ec236a8e8565eac9e
BLAKE2b-256 8cfdf89b4f7e122d71c8c63198e1aeab4f558e40cf8f81c3b5245eba8ed4365f

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