StoryTeller is a Python application that transforms text scripts into immersive audio dramas using AI-powered text-to-speech technology. Create professional-quality audio content with different character voices, perfect for podcasts, audiobooks, or interactive storytelling.
- ποΈ Multi-Character Voice Generation: Assign unique AI voices to different characters
- π΅ Automatic Audio Combination: Programmatically combines individual audio segments
- π§ Easy Configuration: Simple character-to-voice mapping
- π Script Processing: Automatically cleans emotional cues and stage directions
- π― Professional Output: Generates high-quality WAV audio files
- π οΈ Standalone Tools: Includes utility scripts for audio processing
- π€ AI Story Conversion: Convert any story text into drama script format using Google Gemini
- Python 3.8 or higher
- Deepgram API key (Get one here)
- Google API key (Get one here) - for story conversion feature
-
Clone the repository
git clone https://github.com/yourusername/storyteller.git cd storyteller -
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp env.example .env # Edit .env and add your Deepgram API key -
Run the audio drama generator
python src/storyteller/example.py
-
Configure your script in
src/storyteller/example.py:DRAMA_SCRIPT = [ {"character": "NARRATOR", "line": "Once upon a time..."}, {"character": "HERO", "line": "I will save the day!"}, {"character": "VILLAIN", "line": "Not if I can help it!"}, ]
-
Map characters to voices:
VOICE_MAP = { "NARRATOR": "aura-asteria-en", "HERO": "aura-luna-en", "VILLAIN": "aura-asteria-en", }
-
Run the generator:
python src/storyteller/example.py
StoryTeller supports Deepgram's Aura voice models:
aura-asteria-en- Clear, professional narrator voiceaura-luna-en- Warm, engaging character voiceaura-stella-en- Energetic, dynamic voiceaura-athena-en- Authoritative, commanding voiceaura-hera-en- Sophisticated, elegant voiceaura-orion-en- Deep, resonant voiceaura-arcas-en- Friendly, approachable voiceaura-perseus-en- Strong, heroic voiceaura-angus-en- Warm, fatherly voiceaura-orpheus-en- Melodic, artistic voiceaura-helios-en- Bright, optimistic voiceaura-zeus-en- Powerful, authoritative voice
Note: Voice availability depends on your Deepgram plan.
# Combine specific audio files
python scripts/combine_audio.py output.wav file1.wav file2.wav file3.wav
# Combine all files in a directory
python scripts/combine_audio.py final_drama.wav audio_segments/*.wavThe clean_text() function automatically removes stage directions:
# Input: "(Sad voice) I guess I'll just go home."
# Output: "I guess I'll just go home."The new story conversion feature allows you to convert any story text into a drama script format using Google Gemini.
from storyteller.example import convert_story_to_drama_script
# Your story text
story = """
Sarah was walking through the forest when she heard a strange noise behind her.
She turned around quickly, but there was nothing there. The wind rustled the leaves
above her head. "Hello?" she called out nervously. A voice replied from somewhere
in the trees: "Don't be afraid, Sarah. I've been waiting for you."
"""
# Convert to drama script
drama_script = convert_story_to_drama_script(story)
# The result will be a list of dictionaries like:
# [
# {"character": "NARRATOR", "line": "Sarah was walking through the forest..."},
# {"character": "SARAH", "line": "(nervously) Hello?"},
# {"character": "MYSTERIOUS VOICE", "line": "Don't be afraid, Sarah..."}
# ]Run the test script to try the conversion feature:
python test_story_conversion.pyThis will:
- Test the conversion with a sample story
- Allow you to input your own story for conversion
- Display the generated drama script
Once you have a converted drama script, you can use it with the audio generation:
# Convert your story
drama_script = convert_story_to_drama_script(your_story)
# Replace the DRAMA_SCRIPT in example.py with your converted script
# Then run the audio generation
build_audio_drama()StoryTeller/
βββ src/
β βββ storyteller/ # Main package
β β βββ __init__.py
β β βββ main.py # Application entry point
β β βββ config.py # Configuration management
β β βββ example.py # Audio drama generator
β β βββ models/ # Data models
β β βββ services/ # Business logic
β β βββ api/ # API endpoints
β β βββ utils/ # Utility functions
β βββ tests/ # Test files
βββ scripts/ # Utility scripts
β βββ dev_server.py # Development server
β βββ combine_audio.py # Audio file combiner
βββ docs/ # Documentation
βββ requirements.txt # Production dependencies
βββ requirements-dev.txt # Development dependencies
βββ env.example # Environment variables template
βββ README.md # This file
Create a .env file with the following variables:
# Required
DEEPGRAM_API_KEY=your_deepgram_api_key_here
# Optional
DEBUG=True
LOG_LEVEL=INFO
LOG_FILE=logs/app.logCustomize character voices by modifying the VOICE_MAP:
VOICE_MAP = {
"NARRATOR": "aura-asteria-en",
"CHARACTER1": "aura-luna-en",
"CHARACTER2": "aura-orion-en",
# Add more characters as needed
}# Install development dependencies
pip install -r requirements-dev.txt
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
# Run linting
black src/
isort src/
flake8 src/# Run all tests
pytest
# Run with coverage
pytest --cov=src/storyteller
# Run specific test file
pytest src/tests/test_main.pyMain function that generates audio for all script lines and combines them.
Combines multiple WAV files into a single audio file.
Removes stage directions and emotional cues from dialogue.
Converts any story text into a drama script format using Google Gemini.
Parameters:
story_text(str): The input story text to convert
Returns:
List[Dict[str, str]]: A list of dictionaries with 'character' and 'line' keys
Example:
story = "Once upon a time, Alice found a magical book..."
script = convert_story_to_drama_script(story)
# Returns: [{"character": "NARRATOR", "line": "Once upon a time..."}, ...]Loads configuration from environment variables and .env file.
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Deepgram for providing excellent text-to-speech API
- The Python community for amazing audio processing libraries
- Contributors and users who help improve StoryTeller
- π Documentation
- π Report Issues
- π¬ Discussions
- π§ Contact
Made with β€οΈ for storytellers everywhere