Files
xiaoxia-saas/packages/shared/config.py
T
用户CI Test 506eae98f1
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 4s
CI/CD Pipeline / Production Browser E2E (pull_request) Failing after 1625h8m13s
CI/CD Pipeline / Deploy Production (pull_request) Failing after 1625h8m16s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 1625h8m16s
CI/CD Pipeline / Build Production Runtime Images (pull_request) Failing after 1625h8m18s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 1625h8m16s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Failing after 1625h8m18s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
fix: CosyVoice全量重写 - 适配DashScope百炼API
- 配置更新:base_url改为api/v1,model改为cosyvoice-v3.5-plus,新增clone_model=voice-enrollment
- 音色克隆:适配customization接口 + voice-enrollment模型 + create_voice action
- 状态查询:适配同路径query_voice action(POST),返回DEPLOYING/OK/UNDEPLOYED
- 语音合成:适配SpeechSynthesizer非流式同步接口,直接返回audio_url
- 新增audio_url_signer钩子:对私有bucket音频URL预签名(slash_safe=True)
- voice_clone workflow适配:voice_id替代task_id,status=OK标记ready
- tts_job workflow适配:同步接口直接返回,无task_id时自动重新合成兜底
- API端+Worker端依赖注入OSS预签名函数
- 单元测试:36个service测试 + 18个workflow测试,全部通过
2026-07-10 22:17:07 +08:00

68 lines
2.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Shared settings for API and Worker services."""
import os
from typing import Optional
from pydantic_settings import BaseSettings, SettingsConfigDict
class SharedSettings(BaseSettings):
"""Settings shared between API and Worker services."""
# Database
database_url: str = "postgresql+psycopg://postgres:postgres@localhost:5432/xiaoxia_saas"
database_pool_size: int = 20
database_max_overflow: int = 40
database_pool_timeout: int = 30
database_pool_recycle: int = 3600
# Redis
redis_url: str = "redis://localhost:6379/0"
# Celery
celery_broker_url: str = "redis://localhost:6379/0"
celery_result_backend: str = "redis://localhost:6379/1"
# OSS Aliyun
oss_endpoint: str = "oss-cn-hangzhou.aliiyuncs.com"
oss_access_key_id: str = ""
oss_access_key_secret: str = ""
oss_bucket_name: str = "xiaoxia-autocut"
# CosyVoice (阿里云百炼语音合成)
cosyvoice_api_key: str = ""
cosyvoice_base_url: str = "https://dashscope.aliyuncs.com/api/v1"
cosyvoice_model: str = "cosyvoice-v3.5-plus"
cosyvoice_voice: str = "longxiaochun" # 默认音色
cosyvoice_sample_rate: int = 22050
cosyvoice_format: str = "mp3" # 输出格式:mp3/wav/pcm
# 音色克隆模型名(固定为 voice-enrollment)
cosyvoice_clone_model: str = "voice-enrollment"
# Environment
environment: str = "development"
auto_create_schema: bool = False
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=False,
extra="ignore",
)
_settings: Optional[SharedSettings] = None
def get_shared_settings() -> SharedSettings:
"""Get shared settings instance (global singleton)."""
global _settings
if _settings is None:
env = os.getenv("APP_ENV", "development")
env_file = f".env.{env}" if env != "development" else ".env"
if os.path.exists(env_file):
_settings = SharedSettings(_env_file=env_file)
else:
_settings = SharedSettings()
return _settings