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()

# Stream audio chunks
for chunk in client.stream("Hello world!", voice="antoine"):
    # chunk is raw PCM bytes (int16, 48kHz, mono)
    process_audio(chunk)

Usage

Basic Streaming

from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Stream and save to file
with open("output.pcm", "wb") as f:
    for chunk in client.stream("Welcome to Orpheus TTS!", voice="antoine"):
        f.write(chunk)

Save as WAV

import wave
from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Get complete audio
audio_data = client.stream_to_bytes("Hello, this is a test.", voice="antoine")

# Save as WAV file
with wave.open("output.wav", "wb") as wav:
    wav.setnchannels(1)        # mono
    wav.setsampwidth(2)        # 16-bit
    wav.setframerate(48000)    # 48kHz
    wav.writeframes(audio_data)

Async Streaming

import asyncio
from orpheus_tts import OrpheusClient

async def main():
    client = OrpheusClient()
    
    async for chunk in client.stream_async("Async streaming!", voice="antoine"):
        await process_audio_async(chunk)

asyncio.run(main())

Real-time Playback with PyAudio

import pyaudio
from orpheus_tts import OrpheusClient

client = OrpheusClient()

# Initialize PyAudio
p = pyaudio.PyAudio()
stream = p.open(
    format=pyaudio.paInt16,
    channels=1,
    rate=48000,
    output=True
)

# Stream and play
for chunk in client.stream("This plays in real-time!", voice="antoine"):
    stream.write(chunk)

stream.stop_stream()
stream.close()
p.terminate()

Available Voices

from orpheus_tts import VOICES

print(VOICES)

Configuration

client = OrpheusClient(
    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="antoine",
    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()

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

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.0.tar.gz (7.5 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.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 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.0.tar.gz
Algorithm Hash digest
SHA256 e4c79af236cc4d8a97b22d3da88cfa2b5ad7aff2bdd46ac7a7b28b1b7158df6e
MD5 41984fcdde07fdfb9ceae3b2f073f1e9
BLAKE2b-256 e0cd3c2ea6a2e95c88ffd2094cecd39e32bee0543444b257aaf664c5a568c93a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06138c0ee24986dbb5361f693443eb4888a9b4a0cf9deda2d37119cbdf9caa70
MD5 21b2338c5356691513683bfb523d26d0
BLAKE2b-256 d617ccab50596e6074f3a9730130de23d5e5d4be0dcc77f8865fcd58485cd681

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