feat: 添加 TTS 语音名称常量并更新 TTS 服务逻辑

- 在 constants.py 中新增 TTS_VOICE_NAMES 列表,包含多个语音名称。
- 更新 tts_service.py 中的语音配置逻辑,确保使用请求中的语音名称(如果有效),否则回退到默认配置。
This commit is contained in:
snaily
2025-07-10 01:03:20 +08:00
parent eed62caa78
commit f6d64dd850
2 changed files with 14 additions and 2 deletions
+2 -1
View File
@@ -8,6 +8,7 @@ from typing import Optional
from google import genai
from app.config.config import settings
from app.core.constants import TTS_VOICE_NAMES
from app.database.services import add_error_log, add_request_log
from app.domain.openai_models import TTSRequest
from app.log.logger import get_openai_logger
@@ -47,7 +48,7 @@ class TTSService:
"speech_config": {
"voice_config": {
"prebuilt_voice_config": {
"voice_name": settings.TTS_VOICE_NAME
"voice_name": request.voice if request.voice in TTS_VOICE_NAMES else settings.TTS_VOICE_NAME
}
}
},