Quickstart

Make your first text-to-speech API call in 5 minutes

1

Get your API key

  1. Sign up at console.sws.speechify.com
  2. Go to API Keys
  3. Copy your default API key (or create a new one)

Set it as an environment variable:

$export SPEECHIFY_API_KEY="your-api-key-here"
2

Install the SDK

$pip install speechify-api
3

Generate speech

1from speechify import Speechify
2
3client = Speechify() # uses SPEECHIFY_API_KEY env var
4
5response = client.tts.audio.speech(
6 input="Hello! This is my first Speechify API call.",
7 voice_id="george",
8 audio_format="mp3",
9)
10
11with open("output.mp3", "wb") as f:
12 f.write(response.audio_data)
13
14print(f"Audio saved ({len(response.audio_data)} bytes)")
4

Play the audio

Open output.mp3 in any audio player, or play it from the terminal:

$# macOS
$afplay output.mp3
$
$# Linux
$aplay output.mp3

Choose a voice

The API includes built-in voices. List them to find one that fits your use case:

1voices = client.tts.voices.list()
2
3for voice in voices:
4 print(f"{voice.id}: {voice.display_name} ({voice.gender})")

Popular built-in voices: george, henry, carly, sophia.

You can also clone any voice from a short audio sample.

Add emotion

Use SSML to control how the voice sounds:

1<speak>
2 <speechify:style emotion="cheerful">
3 Great news! Your order has been shipped!
4 </speechify:style>
5</speak>

Pass SSML as the input parameter — the API detects it automatically. See Emotion Control for the full list of 13 supported emotions.

Next steps