Commit Graph

2 Commits

Author SHA1 Message Date
Li Hongmin
0134020564 feat: add Azure Speech TTS provider
Add support for Azure Speech Service text-to-speech with high-quality neural voices.

Features:
- Azure TTS provider with 400+ neural voices
- Support for 100+ languages and regional accents
- High-quality Chinese voices (zh-CN-XiaoxiaoNeural, YunxiNeural, etc.)
- Environment variable support: AZURE_SPEECH_API_KEY, AZURE_SPEECH_REGION
- Configuration via moltbot.json messages.tts.azure section
- SSML-based voice synthesis with proper XML escaping

Technical details:
- Endpoint: https://{region}.tts.speech.microsoft.com/cognitiveservices/v1
- Headers: Ocp-Apim-Subscription-Key, X-Microsoft-OutputFormat
- Request body: SSML XML format
- Response: audio/mpeg binary stream
- Default: audio-24khz-48kbitrate-mono-mp3

Benefits over Edge TTS:
- Higher quality neural voices with better prosody
- More voice options (400+ vs limited Edge TTS set)
- Unified Azure billing with GPT models
- Custom voice support (preview)
- Fine-grained SSML control

Performance:
- Latency: ~500-900ms for typical sentences
- Works seamlessly with Telegram voice messages

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-01-28 17:44:26 +09:00
Li Hongmin
9e857e6154 feat: add Azure provider support
Add support for Azure-hosted OpenAI-compatible models including OpenAI (GPT-4, GPT-5.2), DeepSeek, and other compatible models.

Implementation:
- Add Azure provider configuration with auto-discovery from environment
- Environment variables: AZURE_ENDPOINT, AZURE_API_KEY, AZURE_DEPLOYMENT, AZURE_API_VERSION
- URL fix middleware to handle Azure's specific URL format
- Tool call ID sanitization for Azure's 40-character limit
- Onboarding wizard support for interactive Azure setup
- Comprehensive tests for configuration and URL handling
- Documentation with setup guide and troubleshooting

Technical details:
- Azure uses different URL structure: {endpoint}/openai/deployments/{deployment}/chat/completions?api-version={version}
- OpenAI SDK constructs URLs incorrectly for Azure, placing query params before path
- URL fix middleware intercepts and corrects malformed URLs transparently
- Supports max_completion_tokens for newer models via compat config
- Tool call IDs automatically truncated to 40 characters for Azure compatibility

Onboard integration:
- Added Azure to auth choice groups (appears after OpenAI)
- Interactive prompts for endpoint, deployment name, API key, and API version
- Auto-discovery from environment variables if already configured
- Supports both manual configuration and environment variable detection

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-01-28 17:33:34 +09:00