Home Knowledge Base Text-to-Speech Synthesis

Text-to-Speech Synthesis

TTS Options

Model/ServiceTypeQualitySpeed
OpenAI TTSAPIExcellentFast
ElevenLabsAPIExcellentFast
Coqui TTSOpen sourceGoodMedium
BarkOpen sourceExcellentSlow
XTTSOpen sourceExcellentMedium

OpenAI TTS

from openai import OpenAI

client = OpenAI()

response = client.audio.speech.create(
    model="tts-1-hd",
    voice="nova",  # alloy, echo, fable, onyx, nova, shimmer
    input="Hello, this is a test of text to speech."
)

response.stream_to_file("output.mp3")

ElevenLabs

from elevenlabs import generate, play

audio = generate(
    text="Hello world!",
    voice="Rachel",
    model="eleven_multilingual_v2"
)

play(audio)

Open Source: Coqui TTS

from TTS.api import TTS

tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")

# Generate with voice cloning
tts.tts_to_file(
    text="This is using voice cloning.",
    speaker_wav="reference_voice.wav",
    language="en",
    file_path="output.wav"
)

Voice Cloning Clone a voice from audio sample:

# XTTS voice cloning
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2")

audio = tts.tts(
    text="Hello in the cloned voice.",
    speaker_wav="sample_voice.wav",  # 6+ second sample
    language="en"
)

Streaming TTS

from openai import OpenAI

client = OpenAI()

with client.audio.speech.with_streaming_response.create(
    model="tts-1",
    voice="nova",
    input="Streaming audio sentence by sentence..."
) as response:
    response.stream_to_file("streamed.mp3")

Use Cases

Use CaseRequirements
AudiobooksNatural prosody, long-form
Voice assistantsLow latency, streaming
AccessibilityClear articulation
Content creationVoice variety, cloning
PodcastsHigh quality, natural

Considerations

FactorConsideration
LatencyAPI faster, local more consistent
QualityHD models sound more natural
CostAPI per-character, local fixed
Voice varietyAPIs have more options
PrivacyLocal for sensitive content

Best Practices

ttsvoice synthesisspeech

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.