ElevenLabs TTS Operator
Overview
Section titled “Overview”The ElevenLabs TTS LOP generates high-quality, natural-sounding speech from text using the ElevenLabs API. It utilizes WebSockets for low-latency audio streaming directly into a TouchDesigner CHOP, making it suitable for real-time applications. It also supports saving the generated audio to local files and recalling previously generated audio from ElevenLabs’ history or local cache.
Requirements
Section titled “Requirements”- Python Packages:
websockets
: For streaming audio.requests
: For fetching voices and history.numpy
: For audio data handling.soundfile
: For saving audio files (install viapip install soundfile
).- Install these via the ChatTD Python Manager.
- ChatTD Operator: Required for dependency management, API key storage (optional), and asynchronous task execution. Ensure the
ChatTD Operator
parameter on the ‘About’ page points to your configured ChatTD instance. - ElevenLabs API Key: A valid API key from your ElevenLabs account.
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”- Input DAT (
input_message
, optional): IfText Input Source
is set toinput_dat
, the text content of this DAT is used for synthesis.
Outputs
Section titled “Outputs”- Output CHOP (
null_audio_out
->store_output
): Contains the streamed or loaded audio data (mono, 24kHz). - History DAT (
history_dat
): Internal table logging local generation jobs initiated by this operator. - API History DAT (
api_history_dat
): Internal table mirroring recent history items fetched from the ElevenLabs API. - Local History DAT (
local_history_dat
): Internal table listing locally saved audio files generated by this operator. - Voices DAT (
voices_dat
): Internal table listing available voices fetched from the API. - Saved Audio Files: Audio can be saved locally (WAV or OGG) in the specified
Save Folder
. - Saved Metadata Files: JSON files containing details about each saved generation are stored in a
metadata
subfolder within the ElevenLabs config directory.
Parameters
Section titled “Parameters”Page: ElevenLabs
Section titled “Page: ElevenLabs” ElevenLabs API Key (Apikey)
op('tts_elevenlabs').par.Apikey
Str - Default:
API KEY LOADED
Get API Key (Getapikey)
op('tts_elevenlabs').par.Getapikey
Pulse - Default:
None
Fetch Available Voices (Getvoices)
op('tts_elevenlabs').par.Getvoices
Pulse - Default:
None
Stability (Stability)
op('tts_elevenlabs').par.Stability
Float - Default:
0.5
- Range:
- 0 to 1
- Slider Range:
- 0 to 1
Similarity Boost (Similarityboost)
op('tts_elevenlabs').par.Similarityboost
Float - Default:
0.8
- Range:
- 0 to 1
- Slider Range:
- 0 to 1
Use Speaker Boost (Usespeakerboost)
op('tts_elevenlabs').par.Usespeakerboost
Toggle - Default:
1
- Options:
- off, on
Text to Speak (Text)
op('tts_elevenlabs').par.Text
Str - Default:
text to speak
Start Streaming (Stream)
op('tts_elevenlabs').par.Stream
Pulse - Default:
None
Stop Streaming (Stop)
op('tts_elevenlabs').par.Stop
Pulse - Default:
None
Clear Stored Audio (Clearaudio)
op('tts_elevenlabs').par.Clearaudio
Pulse - Default:
None
Status (Status)
op('tts_elevenlabs').par.Status
Str - Default:
ElevenLabs API Key loaded.
Active (Active)
op('tts_elevenlabs').par.Active
Toggle - Default:
0
- Options:
- off, on
Playing (Playing)
op('tts_elevenlabs').par.Playing
Toggle - Default:
0
- Options:
- off, on
Start Playback (Playstart)
op('tts_elevenlabs').par.Playstart
Pulse - Default:
None
Enable Playback Control (Play)
op('tts_elevenlabs').par.Play
Toggle - Default:
1
- Options:
- off, on
Play on Result (Playonresult)
op('tts_elevenlabs').par.Playonresult
Toggle - Default:
1
- Options:
- off, on
Check Credits (Checkcredits)
op('tts_elevenlabs').par.Checkcredits
Pulse - Default:
None
Credit Info (Creditinfo)
op('tts_elevenlabs').par.Creditinfo
Str - Default:
None
Page: Playback
Section titled “Page: Playback” Audio Device Settings Header
Active (Audioactive)
op('tts_elevenlabs').par.Audioactive
Toggle - Default:
1
- Options:
- off, on
Volume (Volume)
op('tts_elevenlabs').par.Volume
Float - Default:
1
- Range:
- 0 to 1
- Slider Range:
- 0 to 1
Save Audio To File Header
Auto Save To Disk (Autosavetodisk)
op('tts_elevenlabs').par.Autosavetodisk
Toggle - Default:
1
- Options:
- off, on
Output Folder (Folder)
op('tts_elevenlabs').par.Folder
Folder - Default:
tts_elevenlabs_outs
Base Name (Name)
op('tts_elevenlabs').par.Name
Str - Default:
tts_elevenlabs1
Auto Version (Autoversion)
op('tts_elevenlabs').par.Autoversion
Toggle - Default:
1
- Options:
- off, on
Save Current Audio (Savefile)
op('tts_elevenlabs').par.Savefile
Pulse - Default:
None
CHOP Outputs Header
Page: History
Section titled “Page: History” Update History (Fetchhistory)
op('tts_elevenlabs').par.Fetchhistory
Pulse - Default:
None
Load Audio File (Loadfile)
op('tts_elevenlabs').par.Loadfile
Pulse - Default:
None
Enable History Playback (Playbackfromhistory)
op('tts_elevenlabs').par.Playbackfromhistory
Toggle - Default:
0
- Options:
- off, on
Playing History Item (Playinghistory)
op('tts_elevenlabs').par.Playinghistory
Toggle - Default:
0
- Options:
- off, on
Loaded Audio File Path (Audiofilepath)
op('tts_elevenlabs').par.Audiofilepath
Str - Default:
None
Page: Callbacks
Section titled “Page: Callbacks” Callbacks Header
Callback DAT (Callbackdat)
op('tts_elevenlabs').par.Callbackdat
DAT - Default:
/DOC_GENERATOR/NETWORK_VIEWER/tts_elevenlabs_callbacks
Create Callbacks (Createcallbacks)
op('tts_elevenlabs').par.Createcallbacks
Pulse - Default:
None
onGenerate (Ongenerate)
op('tts_elevenlabs').par.Ongenerate
Toggle - Default:
1
- Options:
- off, on
onDone (Ondone)
op('tts_elevenlabs').par.Ondone
Toggle - Default:
1
- Options:
- off, on
onPlayStart (Onplaystart)
op('tts_elevenlabs').par.Onplaystart
Toggle - Default:
1
- Options:
- off, on
onPlayEnd (Onplayend)
op('tts_elevenlabs').par.Onplayend
Toggle - Default:
1
- Options:
- off, on
onSave (Onsave)
op('tts_elevenlabs').par.Onsave
Toggle - Default:
1
- Options:
- off, on
Available Callbacks:
onGenerate
onDone
onPlayStart
onPlayEnd
onSave
Example Callback Structure:
def onGenerate(info):
# Called before streaming starts
# info: {'job_id', 'text', 'voice_id', 'model_id'}
print(f"Starting generation job: {info.get('job_id')}")
def onDone(info):
# Called when streaming finishes or errors
# info: {'job_id', 'status', 'message', 'duration', 'text', 'voice_id', 'model_id'}
print(f"Generation finished: {info.get('status')} ({info.get('duration')}s)")
def onPlayStart(info):
# Called when playback starts
# info: {'job_id', 'audio_duration', 'text'}
print(f"Playback started for job: {info.get('job_id')}")
def onPlayEnd(info):
# Called when playback ends
# info: {'job_id', 'audio_duration', 'text'}
print(f"Playback finished for job: {info.get('job_id')}")
def onSave(info):
# Called after audio is saved successfully
# info: {'job_id', 'filepath', 'filename', 'folder', 'duration', 'text'}
print(f"Audio saved to: {info.get('filepath')}")
Page: About
Section titled “Page: About” Bypass (Bypass)
op('tts_elevenlabs').par.Bypass
Toggle - Default:
0
- Options:
- off, on
Show Built-in Parameters (Showbuiltin)
op('tts_elevenlabs').par.Showbuiltin
Toggle - Default:
0
- Options:
- off, on
Version (Version)
op('tts_elevenlabs').par.Version
Str - Default:
1.0.0
Last Updated (Lastupdated)
op('tts_elevenlabs').par.Lastupdated
Str - Default:
2025-04-28
Creator (Creator)
op('tts_elevenlabs').par.Creator
Str - Default:
dotsimulate
Website (Website)
op('tts_elevenlabs').par.Website
Str - Default:
https://dotsimulate.com
ChatTD Operator (Chattd)
op('tts_elevenlabs').par.Chattd
OP - Default:
/dot_lops/ChatTD
Clear Log (Clearlog)
op('tts_elevenlabs').par.Clearlog
Pulse - Default:
None
Convert To Text (Converttotext)
op('tts_elevenlabs').par.Converttotext
Toggle - Default:
0
- Options:
- off, on
Usage Examples
Section titled “Usage Examples”Basic Streaming and Playback
Section titled “Basic Streaming and Playback”1. Enter your ElevenLabs API Key.2. Pulse 'Fetch Available Voices' and select a voice from the 'Voice' menu.3. Select a desired 'Model'.4. Keep 'Text Input Source' as 'parameter'.5. Enter text in 'Text to Speak'.6. Ensure 'Play on Result' is ON.7. Pulse 'Start Streaming'. Audio should stream in and play automatically.
Streaming from Input DAT
Section titled “Streaming from Input DAT”1. Set 'Text Input Source' to 'input_dat'.2. Create a Text DAT and connect it to the first input of the ElevenLabs operator.3. Enter text into the Text DAT.4. Pulse 'Start Streaming'.
Saving Audio Automatically
Section titled “Saving Audio Automatically”1. Ensure 'Auto Save To Disk' is ON.2. Specify an 'Output Folder'.3. Optionally change the 'Base Name' (use `$JOBID` for uniqueness) and 'File Type'.4. Run streaming as usual (e.g., Pulse 'Start Streaming').5. After successful streaming, the audio and metadata files will appear in the specified folder.
Recalling and Playing History
Section titled “Recalling and Playing History”1. Pulse 'Update History' to fetch recent items from the API and local storage.2. Select an item from the 'Audio to Load' menu.3. Pulse 'Load Audio File'. Check 'Status' and 'Loaded Audio File Path'.4. Enable 'Enable History Playback'.5. Use the standard 'Start Playback' pulse to play the loaded audio.
Technical Notes
Section titled “Technical Notes”- Streaming: Uses WebSockets for low-latency audio delivery (PCM format, 24kHz sample rate).
- API Key: Stored securely in a local configuration file (
elevenlabs_config.json
) within the ChatTD environment or project folder. - Dependencies: Requires
websockets
,requests
,numpy
,soundfile
. - Asynchronous: All API communication (streaming, voice fetch, history fetch, credit check) happens asynchronously via ChatTD to avoid blocking TouchDesigner.
- Saving: Audio saved locally requires the
soundfile
library. Metadata is saved in JSON format. - History: Fetches history from the ElevenLabs API (limited items) and scans local save folder for generated files.
- Playback: Uses an internal Audio Device Out CHOP configured via the Playback page parameters.
Related Operators
Section titled “Related Operators”- ChatTD: Provides core services like dependency management and asynchronous task execution.