ElevenLabs 🔊

Create natural-sounding voices with AI text-to-speech, voice cloning, and audio processing.

🎙️

What you can do: Text-to-speech (29 languages), speech-to-speech voice conversion, instant voice cloning, sound effects generation, and audio isolation.

Setup

Add your ElevenLabs API key in the ProtectMyAPI Dashboard.


Text to Speech

Basic TTS

let elevenlabs = ProtectMyAPI.elevenLabsService()
 
let audio = try await elevenlabs.textToSpeech(
    text: "Hello! Welcome to my app. How can I help you today?",
    voiceId: "EXAVITQu4vr4xnSDxMaL", // Sarah
    modelId: .multilingualV2
)
 
// Play the audio
let player = try AVAudioPlayer(data: audio)
player.play()

With Voice Settings

let audio = try await elevenlabs.textToSpeech(
    text: "This is a dramatic reading of the news.",
    voiceId: "EXAVITQu4vr4xnSDxMaL",
    modelId: .multilingualV2,
    voiceSettings: ElevenLabsVoiceSettings(
        stability: 0.3,        // Lower = more expressive
        similarityBoost: 0.8,  // Higher = more like original voice
        style: 0.7,            // Higher = more stylized
        useSpeakerBoost: true  // Enhance clarity
    ),
    outputFormat: .mp3_44100_192
)

Streaming TTS (Real-time)

for try await chunk in elevenlabs.streamTextToSpeech(
    text: "This is a very long text that will be streamed...",
    voiceId: "EXAVITQu4vr4xnSDxMaL"
) {
    // Play each chunk as it arrives
    audioPlayer.append(chunk)
}

Speech to Speech

Convert voice recordings to another voice while preserving emotion:

let converted = try await elevenlabs.speechToSpeech(
    audio: originalRecording,
    voiceId: "targetVoiceId",
    modelId: "eleven_english_sts_v2",
    removeBackgroundNoise: true
)

Voice Cloning

Instant Voice Clone

Create a voice clone from audio samples (minimum 1 minute recommended):

let clonedVoice = try await elevenlabs.createVoiceClone(
    name: "My Custom Voice",
    description: "A warm, friendly voice for my app",
    files: [audioSample1, audioSample2, audioSample3],
    labels: ["accent": "american", "gender": "female"]
)
 
// Use the cloned voice
let audio = try await elevenlabs.textToSpeech(
    text: "Hello from my cloned voice!",
    voiceId: clonedVoice.voiceId
)

Sound Effects

Generate sound effects from text descriptions:

let soundEffect = try await elevenlabs.generateSoundEffect(
    text: "A thunderstorm with heavy rain and distant lightning",
    durationSeconds: 10
)

Audio Isolation

Remove background noise and isolate speech:

let cleanAudio = try await elevenlabs.isolateAudio(
    audio: noisyRecording
)

Available Voices

Default Voices

Voice IDNameStyle
EXAVITQu4vr4xnSDxMaLSarahSoft, warm
21m00Tcm4TlvDq8ikWAMRachelClear, confident
AZnzlk1XvdvUeBnXmlldDomiStrong, expressive
MF3mGyEYCl7XYWbV9V6OElliYoung, bubbly
TxGEqnHWrfWFTfGW9XjXJoshDeep, authoritative
VR6AewLTigWG4xSOukaGArnoldAmerican, casual
pNInz6obpgDQGcFmaJgBAdamDeep, narration
yoZ06aMxZJJ28mfd3POQSamRaspy, dynamic

Models

ModelDescriptionBest For
eleven_multilingual_v229 languages, emotionalMost use cases
eleven_turbo_v2_5Low latencyReal-time apps
eleven_english_sts_v2English speech-to-speechVoice conversion

Voice Settings Guide

SettingRangeEffect
stability0.0 - 1.0Lower = more expressive, Higher = more consistent
similarityBoost0.0 - 1.0Higher = closer to original voice
style0.0 - 1.0Higher = more stylized delivery
useSpeakerBoostboolEnhances clarity

Output Formats

FormatQualityFile Size
mp3_44100_64GoodSmall
mp3_44100_128BetterMedium
mp3_44100_192BestLarge
pcm_16000Raw PCMFor processing
pcm_44100High-res PCMFor processing

Pricing Note

ElevenLabs charges per character. Check their pricing page for current rates.