封装minmax语音克隆接口
This commit is contained in:
parent
8a3404dc2e
commit
a4c4ee1f5b
|
|
@ -4,8 +4,9 @@ import sentry_sdk
|
||||||
from sentry_sdk.integrations.loguru import LoguruIntegration, LoggingLevels
|
from sentry_sdk.integrations.loguru import LoguruIntegration, LoggingLevels
|
||||||
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from .utils.KVCache import KVCache
|
from .utils.KVCache import KVCache
|
||||||
from .router import ffmpeg, cache, comfyui
|
from .router import ffmpeg, cache, comfyui, text2speech
|
||||||
from .config import WorkerConfig
|
from .config import WorkerConfig
|
||||||
|
|
||||||
config = WorkerConfig()
|
config = WorkerConfig()
|
||||||
|
|
@ -82,3 +83,4 @@ async def scalar():
|
||||||
web_app.include_router(ffmpeg.router)
|
web_app.include_router(ffmpeg.router)
|
||||||
web_app.include_router(cache.router)
|
web_app.include_router(cache.router)
|
||||||
web_app.include_router(comfyui.router)
|
web_app.include_router(comfyui.router)
|
||||||
|
web_app.include_router(text2speech.router) # 添加文本转语音路由
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,39 @@ class WorkerConfig(BaseSettings):
|
||||||
comfyui_s3_input: Optional[str] = Field(default="comfyui-input", description="ComfyUI input S3文件夹名")
|
comfyui_s3_input: Optional[str] = Field(default="comfyui-input", description="ComfyUI input S3文件夹名")
|
||||||
comfyui_s3_output: Optional[str] = Field(default="comfyui-output", description="ComfyUI output S3文件夹名")
|
comfyui_s3_output: Optional[str] = Field(default="comfyui-output", description="ComfyUI output S3文件夹名")
|
||||||
|
|
||||||
modal_config: Any = SettingsConfigDict()
|
# MiniMax API 配置
|
||||||
|
# BaseSettings 会自动从环境变量 MINIMAX_GROUP_ID 读取值
|
||||||
|
minimax_group_id: str = Field(
|
||||||
|
default="",
|
||||||
|
description="MiniMax API 组ID"
|
||||||
|
)
|
||||||
|
|
||||||
|
# BaseSettings 会自动从环境变量 MINIMAX_API_KEY 读取值
|
||||||
|
minimax_api_key: str = Field(
|
||||||
|
default="",
|
||||||
|
description="MiniMax API 密钥"
|
||||||
|
)
|
||||||
|
|
||||||
|
# 语音克隆相关配置
|
||||||
|
voice_clone_max_file_size: int = Field(
|
||||||
|
default=20 * 1024 * 1024, # 20MB
|
||||||
|
description="语音克隆最大文件大小限制"
|
||||||
|
)
|
||||||
|
|
||||||
|
voice_clone_allowed_formats: list = Field(
|
||||||
|
default=[".mp3", ".wav", ".m4a", ".aac", ".ogg"],
|
||||||
|
description="语音克隆支持的音频格式"
|
||||||
|
)
|
||||||
|
|
||||||
|
voice_clone_output_dir: str = Field(
|
||||||
|
default="voice_clone/minmax",
|
||||||
|
description="语音克隆输出目录(相对于S3挂载目录)"
|
||||||
|
)
|
||||||
|
|
||||||
|
model_config = SettingsConfigDict(
|
||||||
|
# 自动从环境变量加载,大小写不敏感
|
||||||
|
case_sensitive=False,
|
||||||
|
# 支持从 .env 文件加载(如果存在)
|
||||||
|
env_file=".env",
|
||||||
|
env_file_encoding="utf-8"
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ config = WorkerConfig()
|
||||||
|
|
||||||
app = modal.App(config.modal_app_name,
|
app = modal.App(config.modal_app_name,
|
||||||
include_source=False,
|
include_source=False,
|
||||||
secrets=[modal.Secret.from_name("cf-kv-secret",
|
secrets=[modal.Secret.from_name("cf-kv-secret", environment_name=config.modal_environment),
|
||||||
environment_name=config.modal_environment)])
|
modal.Secret.from_name("minimax-api", environment_name=config.modal_environment)])
|
||||||
|
|
||||||
app.include(media_app)
|
app.include(media_app)
|
||||||
app.include(ffmpeg_app)
|
app.include(ffmpeg_app)
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,12 @@ with fastapi_image.imports():
|
||||||
@app.function(scaledown_window=60,
|
@app.function(scaledown_window=60,
|
||||||
secrets=[
|
secrets=[
|
||||||
modal.Secret.from_name("cf-kv-secret", environment_name='dev'),
|
modal.Secret.from_name("cf-kv-secret", environment_name='dev'),
|
||||||
|
modal.Secret.from_name("minimax-api", environment_name=config.modal_environment)
|
||||||
],
|
],
|
||||||
volumes={
|
volumes={
|
||||||
config.S3_mount_dir: modal.CloudBucketMount(
|
config.S3_mount_dir: modal.CloudBucketMount(
|
||||||
bucket_name=config.S3_bucket_name,
|
bucket_name=config.S3_bucket_name,
|
||||||
secret=modal.Secret.from_name("aws-s3-secret",
|
secret=modal.Secret.from_name("aws-s3-secret", environment_name=config.modal_environment),
|
||||||
environment_name=config.modal_environment),
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue