No project description provided
Project description
Deeptune Python Library
The official Python API for Deeptune. Deeptune brings the most human-like text to speech and voice cloning to your project in only a few lines of code.
📖 API & Docs
Check out our documentation.
Installation
pip install deeptune
Usage
Instantiate and use the client with the following:
from deeptune.client import Deeptune
from deeptune.utils import play
client = Deeptune(
api_key="YOUR_API_KEY",
)
audio = client.text_to_speech.generate(
text="Wow, Deeptune's text to speech API is amazing!",
voice="d770a0d0-d7b0-4e52-962f-1a41d252a5f6",
)
play(audio)
Using Prompt Audio
If you prefer to manage voices on your own, you can use your own audio file as a reference for the voice clone.
Using a URL prompt
from deeptune.client import Deeptune
from deeptune.utils import play
client = Deeptune(
api_key="YOUR_API_KEY",
)
audio = client.text_to_speech.generate_from_prompt(
text="Wow, Deeptune's text to speech API is amazing!",
prompt_audio="https://deeptune-demo.s3.amazonaws.com/Michael.wav",
)
play(audio)
Using a file prompt
import base64
from deeptune.client import Deeptune
from deeptune.utils import play
client = Deeptune(
api_key="YOUR_API_KEY",
)
# Open the file and read its contents as bytes
with open("Michael.wav", "rb") as audio_file:
audio_bytes = audio_file.read()
# Encode the bytes to base64
audio_base64 = base64.b64encode(audio_bytes).decode("utf-8")
audio = client.text_to_speech.generate_from_prompt(
text="Wow, Deeptune's text to speech API is amazing!",
prompt_audio=f"data:audio/wav;base64,{audio_base64}",
)
play(audio)
Voices
You can also store and manage voices inside of Deeptune.
# Get all available voices
voices = client.voices.list()
print(voices)
# Get a specific voices
voice = client.voices.get(voice_id="d770a0d0-d7b0-4e52-962f-1a41d252a5f6")
print(voice)
# Create a new cloned voice
voice = client.voices.create(
name="Cool Name",
file=open("./Michael.wav", "rb")
)
print(voice)
# Update an existing voice
voice = client.voices.update(
voice_id=voice.id,
name="Updated Name",
file=open("./Michael.wav", "rb"),
)
print(voice)
# Delete an existing voice
client.voices.delete(voice.id)
Saving the output
Saving manually
The generate
and generate_from_prompt
endpoints return an iterator of bytes. Make sure to get all of the bytes before writing as demonstrated below.
audio = client.text_to_speech.generate(
text="Wow, Deeptune's text to speech API is amazing!",
voice="d770a0d0-d7b0-4e52-962f-1a41d252a5f6",
)
audio_bytes = b"".join(audio)
# Now, you can save however you'd like
with open("output.mp3", "wb") as audio_file:
audio_file.write(audio_bytes)
Using built in utils
The also has inbuilt play
, save
, and stream
utility methods. Under the hood, these methods use ffmpeg and mpv to play audio streams.
from deeptune.utils import play, save, stream
# plays audio using ffmpeg
play(audio)
# streams audio using mpv
stream(audio)
# saves audio to file
save(audio, "my-file.mp3")
Async Client
The SDK also exports an async
client so that you can make non-blocking calls to our API.
from deeptune.client import Deeptune
from deeptune.utils import play
client = AsyncDeeptune(
api_key="YOUR_API_KEY",
)
audio = await client.text_to_speech.generate_from_prompt(
text="Wow, Deeptune's text to speech API is amazing!",
voice="d770a0d0-d7b0-4e52-962f-1a41d252a5f6",
)
play(audio)
Contributing
While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!
On the other hand, contributions to the README are always very welcome!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file deeptune-1.0.3.tar.gz
.
File metadata
- Download URL: deeptune-1.0.3.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1071-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aa27d281ab1e1effbac5919c4f5d22d15b8f70a9e8ac6e62a3b660ddd78fcec |
|
MD5 | 49ff4a3e89022c6ab5240ce1684cc425 |
|
BLAKE2b-256 | 0eed9fbfe0ebb37e43fc8795d67c1906a40bd63043d7f5e2f25692a38e69dfa6 |
File details
Details for the file deeptune-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: deeptune-1.0.3-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1071-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f89fe5f0e750f5401901db3e0471c32fc33d77e3a7bed3572bd90d9e92268e0 |
|
MD5 | 5b0b1b63d631d8bb9846fafb2306b7e9 |
|
BLAKE2b-256 | 4b95c2e6a348bd33b339aef59874cb1aa826fe86d7b4cb06db1d6d848429c27a |