A Python client for interacting with the OuteAI Text-to-Speech (TTS) API during early access.
- Customizable Parameters: Adjust generation settings, including temperature, repeat penalty, and speaker selection.
-
Convenient Audio Handling: Save audio outputs as
.wav
files with a simple interface.
pip install outeai
To use the TTS client, you need an API token from OuteAI. Replace "your_api_token"
with your actual token.
from outeai.api.v1 import TTSClient
# Initialize the client
client = TTSClient(token="your_api_token")
Provide the required parameters (text, model ID, speaker, etc.) to generate speech.
audio_output = client.generate(
text="Speech synthesis is the artificial production of human speech.",
model_id="outetts-0.3-500m",
speaker="en_male_1"
)
# Save the audio to a file
audio_output.save("output_audio.wav")
-
text
: The text to be converted into speech. (Required) -
model_id
: The ID of the TTS model to use. (Required) -
temperature
: Controls the randomness of the output. Value between0.1
and1.0
. (Default:0.1
) -
repeat_penalty
: Penalizes repeated sequences. Value between1.0
and2.0
. (Default:1.1
) -
speaker
: The speaker voice ID. (Default:en_male_1
) -
show_notice
: Whether to show API usage notices. (Default:True
)
The client raises clear exceptions for invalid inputs or API issues:
-
ValueError
: For invalid parameter values or API errors. -
requests.RequestException
: For network-related issues.
try:
audio_output = client.generate(
text="Speech synthesis is the artificial production of human speech.",
model_id="outetts-0.3-500m",
speaker="en_female_1",
temperature=0.4,
repeat_penalty=1.1
)
audio_output.save("speech.wav")
except Exception as e:
print(f"An error occurred: {e}")