diff --git a/.env.example b/.env.example index 3bcd412c9..ae43db016 100755 --- a/.env.example +++ b/.env.example @@ -44,9 +44,14 @@ OSS_ACCESS_KEY_SECRET=your-access-key-secret OSS_BUCKET_NAME=xiaoxia-autocut # ==================== CosyVoice 语音合成配置 ==================== +# 注意:base_url 只需写到 /api/v1,具体路径由代码拼接 +# 模型: cosyvoice-v3-flash (推荐,支持系统音色,性价比高) +# cosyvoice-v3-plus (高质量,系统音色少) +# cosyvoice-v3.5-flash / cosyvoice-v3.5-plus (仅支持克隆/设计音色,无系统音色) +# 音色: v3系列系统音色带 _v3 后缀,如 longxiaochun_v3, longxiaoxia_v3, longanyang (无后缀) COSYVOICE_API_KEY=your-cosyvoice-api-key -COSYVOICE_BASE_URL=https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio -COSYVOICE_MODEL=cosyvoice-v1 -COSYVOICE_VOICE=longxiaochun +COSYVOICE_BASE_URL=https://dashscope.aliyuncs.com/api/v1 +COSYVOICE_MODEL=cosyvoice-v3-flash +COSYVOICE_VOICE=longxiaochun_v3 COSYVOICE_SAMPLE_RATE=22050 COSYVOICE_FORMAT=mp3 diff --git a/.env.production.example b/.env.production.example old mode 100644 new mode 100755 index 6082c3926..43cb2312d --- a/.env.production.example +++ b/.env.production.example @@ -42,10 +42,15 @@ OSS_DIRECT_UPLOAD_MAX_MB=2000 OSS_DIRECT_UPLOAD_EXPIRE_SECONDS=900 # ==================== CosyVoice 语音合成(必须配置)==================== +# 注意:base_url 只需写到 /api/v1,具体路径由代码拼接 +# 模型: cosyvoice-v3-flash (推荐,支持系统音色,性价比高) +# cosyvoice-v3-plus (高质量,系统音色少) +# cosyvoice-v3.5-flash / cosyvoice-v3.5-plus (仅支持克隆/设计音色,无系统音色) +# 音色: v3系列系统音色带 _v3 后缀,如 longxiaochun_v3, longxiaoxia_v3, longanyang (无后缀) COSYVOICE_API_KEY=CHANGE_ME_COSYVOICE_API_KEY -COSYVOICE_BASE_URL=https://dashscope.aliyuncs.com/api/v1/services/aigc/text2audio -COSYVOICE_MODEL=cosyvoice-v1 -COSYVOICE_VOICE=longxiaochun +COSYVOICE_BASE_URL=https://dashscope.aliyuncs.com/api/v1 +COSYVOICE_MODEL=cosyvoice-v3-flash +COSYVOICE_VOICE=longxiaochun_v3 COSYVOICE_SAMPLE_RATE=22050 COSYVOICE_FORMAT=mp3 diff --git a/packages/application/cosyvoice_service.py b/packages/application/cosyvoice_service.py index 76863b38a..cd6bd1dd8 100755 --- a/packages/application/cosyvoice_service.py +++ b/packages/application/cosyvoice_service.py @@ -131,6 +131,26 @@ class CosyVoiceService: ) self._owns_client = http_client is None + # 启动时打印配置(脱敏),方便排查环境变量覆盖问题 + if self._owns_client: + masked_key = "" + if self._api_key: + if len(self._api_key) > 8: + masked_key = f"{self._api_key[:4]}...{self._api_key[-4:]}" + else: + masked_key = "***" + logger.info( + "[CosyVoice Config] 初始化配置: " + "model=%s, base_url=%s, default_voice=%s, " + "sample_rate=%d, format=%s, api_key=%s", + self._model, + self._base_url, + getattr(settings, "cosyvoice_voice", "(unset)"), + settings.cosyvoice_sample_rate, + settings.cosyvoice_format, + masked_key or "(empty)", + ) + def __enter__(self) -> CosyVoiceService: return self