Summary
Replace Azure TTS as the primary TTS provider with Edge TTS, which is completely free and requires no API key. Keep Azure TTS as a fallback option.
Motivation
Current problems with Azure TTS:
- Rate limiting: 467 calls in 24 hours resulted in 29 HTTP 429 errors (6% failure rate)
- API quota limits on Free F0 tier (20 requests/minute)
- Requires API key management and monitoring
Edge TTS advantages:
- ✅ 100% FREE - no API key required
- ✅ No rate limits (or very high limits)
- ✅ Same voice quality - uses Microsoft's neural voices
- ✅ Czech language support -
cs-CZ-AntoninNeural (male), cs-CZ-VlastaNeural (female)
- ✅ Proven reliability - used by Microsoft Edge browser internally
Tested Implementation
Python Library (Proof of Concept)
Successfully tested with edge-tts Python library (version 7.2.7):
# Installation
pip install edge-tts
# Test command that works
edge-tts --voice cs-CZ-AntoninNeural \
--text "Dobrý den, toto je Edge TTS." \
--write-media output.mp3
# List available voices
edge-tts --list-voices | grep cs-CZ
Test results:
- File size: 31 KB (short text), 68 KB (longer text)
- Quality: 24 kHz, 48 kbps MP3
- Generation time: ~2-3 seconds
- No errors, 100% success rate
Available Czech voices:
cs-CZ-AntoninNeural - Male voice (tested ✅)
cs-CZ-VlastaNeural - Female voice (tested ✅)
C# Implementation (.NET)
Recommended NuGet package: EdgeTtsSharp version 2.0.6
Installation:
dotnet add package EdgeTtsSharp
GitHub repository: https://github.com/niker/EdgeTtsSharp
NuGet package: https://www.nuget.org/packages/EdgeTtsSharp
Example code (from EdgeTtsSharp documentation):
using EdgeTtsSharp;
// Get Czech male voice
var voice = await EdgeTts.GetVoice("cs-CZ-AntoninNeural");
// Option 1: Get audio stream (starts immediately)
await using var stream = voice.GetAudioStream("Text k přečtení");
// Use stream for playback or further processing
// Option 2: Save directly to file
await voice.SaveAudioToFile("Text k přečtení", "/path/to/output.mp3");
// Option 3: Stream to HTTP response (for API endpoints)
await voice.StreamText(Response.Body, "Text k přečtení");
// Get all available voices
var allVoices = await EdgeTts.GetVoices();
// Get specific voice by short name
var czechVoice = await EdgeTts.GetVoice("cs-CZ-AntoninNeural");
Key features:
- Real-time streaming (starts playback on first audio packet)
- Cross-platform (.NET Standard 2.1)
- Async/await support
- No external dependencies for core functionality
Proposed Implementation
Architecture Changes
Current TTS priority:
- Azure TTS (primary)
- Fallback TTS
Proposed TTS priority:
- Edge TTS (primary) ← NEW
- Azure TTS (fallback - when Edge TTS fails)
- Other fallback TTS
Implementation Steps
-
Add NuGet package:
cd ~/Olbrasoft/VirtualAssistant/src/VirtualAssistant.Voice
dotnet add package EdgeTtsSharp
-
Create EdgeTtsProvider class (similar to existing Azure TTS provider):
- Implement ITtsProvider interface
- Use
EdgeTts.GetVoice("cs-CZ-AntoninNeural")
- Return audio stream or save to file
-
Update TTS service configuration:
- Register EdgeTtsProvider as primary
- Configure voice selection (AntoninNeural for male, VlastaNeural for female)
- Keep Azure TTS configuration for fallback
-
Add error handling:
- Catch EdgeTTS exceptions
- Automatically fall back to Azure TTS on failure
- Log TTS provider used for monitoring
-
Configuration (appsettings.json):
{
"Tts": {
"PrimaryProvider": "EdgeTts",
"EdgeTts": {
"DefaultVoice": "cs-CZ-AntoninNeural",
"FemaleVoice": "cs-CZ-VlastaNeural",
"MaleVoice": "cs-CZ-AntoninNeural"
},
"FallbackProvider": "AzureTts",
"AzureTts": {
"Key": "...",
"Region": "westeurope",
"Voice": "cs-CZ-AntoninNeural"
}
}
}
Testing Checklist
Expected Benefits
- Cost savings: Zero API costs vs current Azure F0 tier limits
- Reliability: No rate limit errors (29 errors eliminated)
- Performance: Same or better generation speed
- Quality: Identical neural voice quality
- Simplicity: No API key management needed
References
Notes
Edge TTS uses Microsoft's internal TTS service (same as Microsoft Edge browser's "Read Aloud" feature). It's legitimate and free to use, but Microsoft may implement rate limiting in the future. Having Azure TTS as fallback ensures reliability.
Tested on: Debian 13 (Trixie), .NET 10, Python 3.13
Library version: edge-tts 7.2.7 (Python), EdgeTtsSharp 2.0.6 (C#)
Test date: 2024-12-14
Summary
Replace Azure TTS as the primary TTS provider with Edge TTS, which is completely free and requires no API key. Keep Azure TTS as a fallback option.
Motivation
Current problems with Azure TTS:
Edge TTS advantages:
cs-CZ-AntoninNeural(male),cs-CZ-VlastaNeural(female)Tested Implementation
Python Library (Proof of Concept)
Successfully tested with edge-tts Python library (version 7.2.7):
Test results:
Available Czech voices:
cs-CZ-AntoninNeural- Male voice (tested ✅)cs-CZ-VlastaNeural- Female voice (tested ✅)C# Implementation (.NET)
Recommended NuGet package:
EdgeTtsSharpversion 2.0.6Installation:
GitHub repository: https://github.com/niker/EdgeTtsSharp
NuGet package: https://www.nuget.org/packages/EdgeTtsSharp
Example code (from EdgeTtsSharp documentation):
Key features:
Proposed Implementation
Architecture Changes
Current TTS priority:
Proposed TTS priority:
Implementation Steps
Add NuGet package:
Create EdgeTtsProvider class (similar to existing Azure TTS provider):
EdgeTts.GetVoice("cs-CZ-AntoninNeural")Update TTS service configuration:
Add error handling:
Configuration (appsettings.json):
{ "Tts": { "PrimaryProvider": "EdgeTts", "EdgeTts": { "DefaultVoice": "cs-CZ-AntoninNeural", "FemaleVoice": "cs-CZ-VlastaNeural", "MaleVoice": "cs-CZ-AntoninNeural" }, "FallbackProvider": "AzureTts", "AzureTts": { "Key": "...", "Region": "westeurope", "Voice": "cs-CZ-AntoninNeural" } } }Testing Checklist
Expected Benefits
References
Notes
Edge TTS uses Microsoft's internal TTS service (same as Microsoft Edge browser's "Read Aloud" feature). It's legitimate and free to use, but Microsoft may implement rate limiting in the future. Having Azure TTS as fallback ensures reliability.
Tested on: Debian 13 (Trixie), .NET 10, Python 3.13
Library version: edge-tts 7.2.7 (Python), EdgeTtsSharp 2.0.6 (C#)
Test date: 2024-12-14