'commit'
This commit is contained in:
@@ -2,7 +2,7 @@ import logging
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from fastapi import APIRouter, HTTPException, Query # 添加Query导入
|
||||
from pydantic import BaseModel
|
||||
|
||||
from Util.GengerateAudio import ByteDanceTTS
|
||||
@@ -36,17 +36,13 @@ class TextToSpeechResponse(BaseModel):
|
||||
request_id: Optional[str] = None
|
||||
|
||||
|
||||
@router.get("/voices/categories")
|
||||
@router.get("/voice-categories")
|
||||
async def get_voice_categories():
|
||||
"""
|
||||
获取所有音色分类接口
|
||||
返回所有可用的音色分类列表
|
||||
"""
|
||||
try:
|
||||
categories = tts_instance.get_all_categories()
|
||||
return {
|
||||
"success": True,
|
||||
"data": categories,
|
||||
"data": categories, # 恢复为原始的 data 字段
|
||||
"message": "获取音色分类成功"
|
||||
}
|
||||
except Exception as e:
|
||||
@@ -56,15 +52,9 @@ async def get_voice_categories():
|
||||
detail=f"获取音色分类失败: {str(e)}"
|
||||
)
|
||||
|
||||
|
||||
@router.get("/voices/by-category/{category}")
|
||||
async def get_voices_by_category(category: str):
|
||||
"""
|
||||
根据分类获取音色列表接口
|
||||
Args:
|
||||
category: 音色分类名称
|
||||
返回指定分类下的所有音色列表
|
||||
"""
|
||||
# 恢复原始的音色列表接口路由
|
||||
@router.get("/voices")
|
||||
async def get_voices_by_category(category: str = Query(...)): # 现在Query已定义
|
||||
try:
|
||||
voices = tts_instance.get_voices_by_category(category)
|
||||
if not voices:
|
||||
@@ -72,7 +62,7 @@ async def get_voices_by_category(category: str):
|
||||
"success": False,
|
||||
"message": f"未找到分类 '{category}' 下的音色"
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"data": voices,
|
||||
@@ -86,7 +76,7 @@ async def get_voices_by_category(category: str):
|
||||
)
|
||||
|
||||
|
||||
@router.get("/voices/all")
|
||||
@router.get("/all")
|
||||
async def get_all_voices():
|
||||
"""
|
||||
获取所有音色分类和音色列表接口
|
||||
|
Reference in New Issue
Block a user