Skip to main content

A Python client for interacting with the Deepdub API

Project description

DeepDub

A Python client for interacting with the DeepDub API, which provides text-to-speech capabilities with voice cloning features.

Installation

pip install deepdub

Features

  • Interact with DeepDub's text-to-speech (TTS) API
  • Add and manage voice profiles
  • Generate speech from text with specified voices
  • Command-line interface for easy usage

Requirements

  • Python 3.11+
  • API key from DeepDub

Usage

Python API Reference

Initialization

from deepdub import DeepdubClient

# Initialize with API key directly
client = DeepdubClient(api_key="your-api-key")

# Or use environment variable
# export DEEPDUB_API_KEY=your-api-key
client = DeepdubClient()

List Voices

# Get all available voices
voices = client.list_voices()

Returns a list of voice dictionaries.

Add Voice

# Add a new voice from audio file
response = client.add_voice(
    data=Path("path/to/audio.mp3"),  # Path object, bytes, or base64 string
    name="Voice Name",
    gender="male",  # "male" or "female"
    locale="en-US",
    publish=False,  # Default: False
    speaking_style="Neutral",  # Default: "Neutral"
    age=0  # Default: 0
)

Returns the server response with voice information.

Text-to-Speech

# Generate speech from text
audio_data = client.tts(
    text="Text to be converted to speech",
    voice_prompt_id="your-voice-id",
    model="dd-etts-2.5",  # Default: "dd-etts-2.5"
    locale="en-US"  # Default: "en-US"
)

# Save the audio data
with open("output.mp3", "wb") as f:
    f.write(audio_data)

Returns binary audio data.

Retroactive Text-to-Speech

# Get URL for generated audio
response = client.tts_retro(
    text="Text to be converted to speech",
    voice_prompt_id="your-voice-id",
    model="dd-etts-2.5",  # Default: "dd-etts-2.5"
    locale="en-US"  # Default: "en-US"
)

# Access the URL
audio_url = response["url"]

Returns a dictionary containing the URL to the generated audio.

Command Line Interface

# List available voices
deepdub list-voices

# Add a new voice
deepdub add-voice --file path/to/audio.mp3 --name "Voice Name" --gender male --locale en-US

# Generate text-to-speech
deepdub tts --text "Hello, world!" --voice-prompt-id your-voice-id

Python API

from deepdub import DeepdubClient

# Initialize with your API key (or set DEEPDUB_API_KEY environment variable)
client = DeepdubClient(api_key="your-api-key")

# List available voices
voices = client.list_voices()
print(voices)

# Generate speech from text
response = client.tts(
    text="Hello, this is a test",
    voice_prompt_id="your-voice-id",
    locale="en-US"
)

# Save the audio output
with open("output.mp3", "wb") as f:
    f.write(response)

Authentication

Set your API key either:

  • As an environment variable: DEEPDUB_API_KEY=your-key
  • When initializing the client: DeepdubClient(api_key="your-key")
  • Using the --api-key flag with CLI commands

License

[License information]

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

deepdub-0.1.17.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

deepdub-0.1.17-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file deepdub-0.1.17.tar.gz.

File metadata

  • Download URL: deepdub-0.1.17.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for deepdub-0.1.17.tar.gz
Algorithm Hash digest
SHA256 14968b4e666f60ffc6976244d42b6e2c1e886f4d1183d4b7a18e4c80102f815d
MD5 38d9731e0a0ddc39bdf67af5607e8857
BLAKE2b-256 799d32bf50e5d32138f2acd1213a379d4ec1b4da2ec25d9f341625f3443edc2a

See more details on using hashes here.

File details

Details for the file deepdub-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: deepdub-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for deepdub-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 6b0a1934f70810385cf84e4eef5b1fe72484f72beaceda60cd14c836b4ac70b7
MD5 ef22f5631b28d43f57d81b7b76bcbedc
BLAKE2b-256 1e969452bc4f9e9640aaa4e1bf488cf68f991ffca183b78b796f625fcf42866b

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