A comprehensive multi-language demonstration suite showcasing text-to-speech functionality using Microsoft Edge's TTS service. This project provides production-ready examples in Python, Dart, Rust, and Java, each implementing advanced TTS features including voice synthesis, SSML support, batch processing, and cross-platform audio playback.
The hello-edge-tts project demonstrates how to integrate with Microsoft Edge's text-to-speech service across different programming languages and paradigms. Each implementation follows consistent API patterns while leveraging language-specific best practices, performance optimizations, and idiomatic code styles.
Perfect for:
- Learning TTS integration across different languages
- Comparing async programming patterns
- Understanding cross-platform audio handling
- Building production TTS applications
- Educational and research purposes
The hello-edge-tts project demonstrates consistent TTS integration patterns across different programming languages, each following the same core workflow:
sequenceDiagram
autonumber
participant APP as Application
participant LIB as TTS Library
participant AUTH as Auth Service
participant WS as TTS WebSocket
participant OUT as Audio Output
Note over LIB,WS: Protocol: WebSocket wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1
APP->>LIB: Start TTS Request
LIB->>AUTH: GET /translate/auth
AUTH-->>LIB: 200 OK {token}
LIB->>WS: Open WebSocket (Bearer token)
WS-->>LIB: 101 Switching Protocols
LIB->>WS: speech.config (JSON)
WS-->>LIB: turn.start
LIB->>WS: SSML for text A
WS-->>LIB: audio.metadata
WS-->>LIB: audio bytes
WS-->>LIB: turn.end
LIB-->>OUT: Play audio A
Note over LIB,WS: Keep connection open for multiple requests
APP->>LIB: Send text B
LIB->>WS: SSML for text B
WS-->>LIB: audio.metadata
WS-->>LIB: audio bytes
WS-->>LIB: turn.end
LIB-->>OUT: Play audio B
Note over LIB,WS: Send new speech.config only if format/voice changes
APP->>LIB: Change format or voice
LIB->>WS: speech.config (new JSON)
WS-->>LIB: turn.start
LIB->>WS: SSML for text C
WS-->>LIB: audio bytes
WS-->>LIB: turn.end
LIB-->>OUT: Play audio C
Note over LIB,WS: Close when batch done, idle, token invalid, or error
LIB->>WS: Close
WS-->>LIB: Close Ack
- π€ High-quality speech synthesis using Microsoft Edge TTS service
- π 400+ voices across 140+ languages and locales
- π΅ SSML support for advanced speech control (rate, pitch, emphasis, breaks)
- π Multiple audio formats (MP3, WAV, OGG)
- π Batch processing for multiple texts
- β‘ Concurrent processing for improved performance
- ποΈ Voice filtering and management by language, gender, and region
- βοΈ Configuration management with JSON/YAML support
- π Cross-platform audio playback with multiple backend support
- π‘οΈ Comprehensive error handling and retry logic
- π Performance optimization with caching and connection pooling
- π― Consistent API design across all language implementations
- π Extensive documentation with examples and troubleshooting
- π§ͺ Unit and integration tests for reliability
- π Easy setup with package managers
- π§ IDE integration support
- π Performance benchmarking tools
| Language | Async Pattern | Key Libraries | Strengths | Best For |
|---|---|---|---|---|
| π Python | async/await |
edge-tts, pygame, aiofiles |
Rapid development, rich ecosystem | Scripting, AI/ML integration, prototyping |
| π― Dart | Future/async/await |
http, args, native audio |
Cross-platform, strong typing | Flutter apps, web development, mobile |
| π¦ Rust | async/await + tokio |
reqwest, rodio, serde |
Memory safety, performance | System programming, high-performance apps |
| β Java | CompletableFuture |
HttpClient, Jackson, javax.sound |
Enterprise features, JVM ecosystem | Enterprise applications, Android apps |
- Runtime: Python 3.7+ (3.9+ recommended)
- Async Model: Native async/await with asyncio
- Audio Backends: pygame (primary), playsound (fallback)
- Unique Features: Rich CLI with argparse, extensive SSML utilities
- Performance: Excellent for I/O-bound operations, GIL limitations for CPU-bound tasks
- Runtime: Dart SDK 2.17+ (3.0+ recommended)
- Async Model: Future-based with isolates support
- Audio Backends: Platform-specific native audio
- Unique Features: Strong null safety, Flutter integration ready
- Performance: Fast startup, efficient memory usage, good concurrency
- Runtime: Rust 1.60+ (1.70+ recommended)
- Async Model: tokio runtime with zero-cost abstractions
- Audio Backends: rodio with multiple platform backends
- Unique Features: Memory safety, zero-cost abstractions, excellent error handling
- Performance: Highest performance, lowest memory footprint, no GC overhead
- Runtime: Java 21+ (LTS with modern features and performance improvements)
- Async Model: CompletableFuture with virtual threads and structured concurrency
- Audio Backends: javax.sound.sampled (built-in)
- Unique Features: Enterprise-grade features, extensive tooling, JVM optimization, modern Java features
- Performance: Excellent JIT optimization, mature profiling tools, good scalability, enhanced GC
- Internet connection for TTS service access
- Audio playback capabilities (speakers/headphones)
- Language-specific runtime (see individual sections)
- Java Implementation: Upgraded to Java 21 LTS with enhanced performance and modern features
- Build System: Eliminated all Maven warnings and improved JAR packaging
- Dependencies: Updated to latest stable versions for security and performance
- Documentation: Comprehensive guides updated with latest requirements
# Navigate to Python directory
cd hello-edge-tts-python
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Run basic example
python hello_tts.py
python hello_tts.py --text 'Hello from Python!' --voice 'en-US-JennyNeural'
python advanced_tts.py --demo ssml# Navigate to Dart directory
cd hello-edge-tts-dart
# Get dependencies
dart pub get
# Run basic example
dart run bin/main.dart
dart run bin/main.dart --text 'Hello from Dart!' --voice 'en-US-JennyNeural'
dart compile exe bin/main.dart -o hello_tts
./hello_tts --list-voices# Navigate to Rust directory
cd rust
# Build project
cargo build
# Run basic example
cargo run
# Try with arguments
cargo run -- --text 'Hello from Rust!' --voice 'en-US-AriaNeural'
# Build optimized release
cargo build --release
./target/release/hello-edge-tts --help# Navigate to Java directory
cd hello-edge-tts-java
mvn compile
# Run basic example
mvn exec:java -Dexec.mainClass='com.example.hellotts.HelloTTS'
mvn exec:java -Dexec.mainClass='com.example.hellotts.HelloTTS' \
-Dexec.args='--text '\''Hello from Java 21!'\'' --voice en-US-GuyNeural'
mvn package
java -jar target/hello-edge-tts-standalone.jar --help# Python: Quick synthesis
python python/hello_tts.py --text 'Welcome to TTS!' --output welcome.mp3
# Dart: List available voices
dart run dart/bin/main.dart --list-voices | head -20
# Rust: Batch processing
echo 'Hello\nWorld\nFrom Rust' | cargo run --manifest-path rust/Cargo.toml -- --batch
# Java: SSML example
mvn exec:java -f java/pom.xml -Dexec.args='--ssml "<speak>Hello <break time=\"1s\"/> World!</speak>"'For detailed setup instructions and advanced usage, see the language-specific README files:
- π Python Implementation - Comprehensive async examples
- π Dart Implementation - Cross-platform development
- π Rust Implementation - High-performance systems
- π Java Implementation - Enterprise applications
hello-edge-tts/
βββ π README.md # This comprehensive guide
βββ π hello-edge-tts-python/ # Python implementation
β βββ π README.md # Python-specific documentation
β βββ π― hello_tts.py # Basic CLI application
β βββ β‘ advanced_tts.py # Advanced features demo
β βββ π§ tts_client.py # Core TTS client
β βββ π΅ audio_player.py # Audio playback handling
β βββ ποΈ config.py # Configuration management
β βββ π ssml_examples.py # SSML demonstrations
β βββ π¦ requirements.txt # Python dependencies
βββ π― hello-edge-tts-dart/ # Dart implementation
β βββ π README.md # Dart-specific documentation
β βββ π¦ pubspec.yaml # Dart dependencies
β βββ π― bin/main.dart # CLI application
β βββ π lib/ # Library modules
β β βββ hello_tts.dart # Main TTS functionality
β β βββ tts_service.dart # TTS service implementation
β β βββ audio_player.dart # Audio playback
β β βββ config_manager.dart # Configuration handling
β βββ π§ͺ test/ # Test files
βββ π¦ hello-edge-tts-rust/ # Rust implementation
β βββ π README.md # Rust-specific documentation
β βββ π¦ Cargo.toml # Rust dependencies
β βββ π― src/ # Source code
β β βββ main.rs # CLI application
β β βββ tts_client.rs # TTS client implementation
β β βββ audio_player.rs # Audio playback
β β βββ config_manager.rs # Configuration management
β βββ π examples/ # Usage examples
β βββ basic_usage.rs # Simple examples
β βββ batch_examples.rs # Batch processing
β βββ ssml_examples.rs # SSML demonstrations
βββ β hello-edge-tts-java/ # Java implementation
β βββ π README.md # Java-specific documentation
β βββ π¦ pom.xml # Maven configuration
β βββ π― src/main/java/ # Main source code
β β βββ com/example/hellotts/
β β βββ HelloTTS.java # Main application
β β βββ TTSClient.java # TTS client
β β βββ AudioPlayer.java # Audio playback
β β βββ Voice.java # Voice model
β β βββ TTSConfig.java # Configuration
β βββ π§ͺ src/test/java/ # Test files
βββ π§ scripts/ # Build and utility scripts
β βββ update-dependencies.sh # Automated dependency updates
β βββ dependency-config.json # Dependency update configuration
βββ ποΈ .github/ # GitHub Actions and workflows
β βββ workflows/ci.yml # CI/CD pipeline
β βββ workflows/dependency-update.yml # Automated dependency updates
β βββ dependabot.yml # Dependabot configuration
βββ π οΈ build.sh # Cross-platform build script
βββ π¦ Makefile # Make-based build automation
βββ π deploy.sh # Deployment script