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
client = DeepdubClient(api_key="your-api-key")
client = DeepdubClient()
List Voices
voices = client.list_voices()
Returns a list of voice dictionaries.
Add Voice
response = client.add_voice(
data=Path("path/to/audio.mp3"),
name="Voice Name",
gender="male",
locale="en-US",
publish=False,
speaking_style="Neutral",
age=0
)
Returns the server response with voice information.
Text-to-Speech
audio_data = client.tts(
text="Text to be converted to speech",
voice_prompt_id="your-voice-id",
model="dd-etts-2.5",
locale="en-US"
)
with open("output.mp3", "wb") as f:
f.write(audio_data)
Returns binary audio data.
Retroactive Text-to-Speech
response = client.tts_retro(
text="Text to be converted to speech",
voice_prompt_id="your-voice-id",
model="dd-etts-2.5",
locale="en-US"
)
audio_url = response["url"]
Returns a dictionary containing the URL to the generated audio.
Command Line Interface
deepdub list-voices
deepdub add-voice --file path/to/audio.mp3 --name "Voice Name" --gender male --locale en-US
deepdub tts --text "Hello, world!" --voice-prompt-id your-voice-id
Python API
from deepdub import DeepdubClient
client = DeepdubClient(api_key="your-api-key")
voices = client.list_voices()
print(voices)
response = client.tts(
text="Hello, this is a test",
voice_prompt_id="your-voice-id",
locale="en-US"
)
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]