mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-08 17:36:37 +08:00
feat: 添加 TTS 语音名称常量并更新 TTS 服务逻辑
- 在 constants.py 中新增 TTS_VOICE_NAMES 列表,包含多个语音名称。 - 更新 tts_service.py 中的语音配置逻辑,确保使用请求中的语音名称(如果有效),否则回退到默认配置。
This commit is contained in:
@@ -77,3 +77,14 @@ DEFAULT_SAFETY_SETTINGS = [
|
|||||||
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "OFF"},
|
{"category": "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold": "OFF"},
|
||||||
{"category": "HARM_CATEGORY_CIVIC_INTEGRITY", "threshold": "BLOCK_NONE"},
|
{"category": "HARM_CATEGORY_CIVIC_INTEGRITY", "threshold": "BLOCK_NONE"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
TTS_VOICE_NAMES = [
|
||||||
|
"Zephyr", "Puck", "Charon", "Kore",
|
||||||
|
"Fenrir", "Leda", "Orus", "Aoede",
|
||||||
|
"Callirhoe", "Autonoe", "Enceladus", "Iapetus",
|
||||||
|
"Umbriel", "Algieba", "Despina", "Erinome",
|
||||||
|
"Algenib", "Rasalgethi", "Laomedeia", "Achernar",
|
||||||
|
"Alnilam", "Schedar", "Gacrux", "Pulcherrima",
|
||||||
|
"Achird", "Zubenelgenubi", "Vindemiatrix", "Sadachbia",
|
||||||
|
"Sadaltager", "Sulafat"
|
||||||
|
]
|
||||||
@@ -8,6 +8,7 @@ from typing import Optional
|
|||||||
from google import genai
|
from google import genai
|
||||||
|
|
||||||
from app.config.config import settings
|
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.database.services import add_error_log, add_request_log
|
||||||
from app.domain.openai_models import TTSRequest
|
from app.domain.openai_models import TTSRequest
|
||||||
from app.log.logger import get_openai_logger
|
from app.log.logger import get_openai_logger
|
||||||
@@ -47,7 +48,7 @@ class TTSService:
|
|||||||
"speech_config": {
|
"speech_config": {
|
||||||
"voice_config": {
|
"voice_config": {
|
||||||
"prebuilt_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user