feat: Add SiliconFlow TTS API support with custom base URL and model selection

This commit adds comprehensive support for using SiliconFlow's TTS API as an alternative to OpenAI, including:

Features:
- Configurable API base URL (Settings > API Base URL)
- TTS model selection dropdown (CosyVoice2-0.5B, OpenAI compatible models)
- Dynamic voice options based on selected model
- Editable voice dropdown (Combobox) supporting custom voice IDs
- Automatic voice formatting for SiliconFlow (model:voice format)
- Debug logging for troubleshooting API calls
- Warning for incorrect base URL format

Changes:
- utils/settings_manager.py: Added api_base_url and tts_model settings
- utils/text_to_mic.py:
  - Added get_available_tts_models() for model options
  - Added get_siliconflow_voices() for SiliconFlow voices
  - Added change_api_base_url() method with validation
  - Added TTS model dropdown in GUI
  - Converted voice dropdown to Combobox for typing support
  - Added on_voice_exit() for validation
  - Updated API call to use selected model and formatted voice
- text-to-mic-cli.py: Added OPENAI_API_BASE_URL and OPENAI_TTS_MODEL env var support
- Readme.md: Updated documentation with SiliconFlow usage instructions

Supported Models:
- FunAudioLLM/CosyVoice2-0.5B (SiliconFlow - multi-language, emotional)
- tts-1, tts-1-hd (OpenAI compatible)
- gpt-4o-mini-tts (OpenAI default)

SiliconFlow Voices (CosyVoice2-0.5B):
- Male: alex, benjamin, charles, david
- Female: anna, bella, claire, diana
- Custom voices via voice ID entry

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Xin Wang
2026-01-27 17:12:34 +08:00
parent 20358adafb
commit 92d20e59e9
4 changed files with 365 additions and 30 deletions

View File

@@ -37,7 +37,9 @@ class SettingsManager:
"play_last_audio": ["ctrl", "shift", "8"],
"cancel_operation": ["ctrl", "shift", "1"]
},
"max_tokens": 750
"max_tokens": 750,
"api_base_url": "",
"tts_model": ""
}
@classmethod