CharacterAI-TTS is an AI-based text-to-speech (TTS). It leverages character.ai advanced technology to synthesize natural-sounding speech from text.
- ✅ Increased character limit from 2048 to 4096 characters per request!
⚠️ Long texts may take more time depending on CharacterAI server load.
- ℹ️ Maximum character limit was 2048 characters.
# Via pip (in the future)
pip install characterai-tts
# For audio playback (optional):
pip install -e .[audio]-
Obtain your token:
⚠️ DO NOT SHARE YOUR TOKEN! It is required to send requests from your account.- Open link https://character.ai/chat/2WPyJRflV_4nTx6_-tuNrhkiiqhDyOsn9O25BR1sDO8
- Open Developer Tools in your browser (usually F12).
- Go to the Network tab.
- Refresh the page or send a message to any character.
- In the list of network requests, click on any request (for example, to
/settings).
- Go to the Headers section.
- Find the Authorization header. It will look like:
Authorization: Token <your_token_here> - Copy only the token part (after
Token). - Set the
CHARACTER_AI_TOKENenvironment variable or create a.envfile in the project root and addCHARACTER_AI_TOKEN=your_copied_token.
Authorization easy (use for mobile) script
If you want to easily obtain your CharacterAI token using your email, you can use the providedauth.pyscript:pip install characterai python auth.py
- Enter your email address.
- Open the sign-in link sent to your email (you can do this on your mobile).
- Paste the link back into the script prompt.
- The script will save your token to
.envin the format required for the library.
This makes it easy to get your token without using browser developer tools.
-
How to get a voice ID:
- Go to the character page on Character AI (for example, this link).
- Choose a voice and click the Share button.
- In the opened window, copy the link. The link will look like:
https://character.ai/?voiceId=2372d060-8401-11ee-b277-020017084944 - Copy the value after
voiceId=(for example,2372d060-8401-11ee-b277-020017084944). - Use this value as the
voiceparameter in the library.
You can use the library in several ways. For simple scripts, use the synchronous method; for async applications, use the async/await method.
from characterai_tts import TTS
# Create a client (default voice – your_voice_id)
client = TTS(api_token="CHARACTER_AI_TOKEN", voice="your_voice_id")
# 1. Speak with the default voice and save to file
client.say("This is an example created with this class")Note: Sometimes CharacterAI-TTS may not synthesize your expected text. This issue is being worked on. Special thanks to PyCharacterAI for enabling TTS with Character AI voices. And special thanks to CharacterAI for the authentication script.
- David Suragan (CharacterAI-TTS)
- Gemini AI
MIT