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.1.tar.gz (7.8 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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 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.1.tar.gz
Algorithm Hash digest
SHA256 7c441d5177cf367b3977fc25b7378b2a5e80577d40b62f949081b340b7a3350f
MD5 f2c5a7bb3c5a9bfd064c87be881ec49b
BLAKE2b-256 5265e5ea05e2105b777bbb18c3a4f95e2bc0beda3fc52acf2df956f26fc8f188

See more details on using hashes here.

File details

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

File metadata

  • Download URL: orpheus_tts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e67093bc405c9a8853f4743695bc32cb9687b6a310c2b13423fb706cff27fdd
MD5 83e3354be3eee56f2c38184891ed8a25
BLAKE2b-256 45fb0edbae42b9fff9fdfca7cc40fdbffd5b5f3aabb5b8941d6e2cbac1b0a279

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