Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions astrbot/core/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,7 @@
"enable": False,
"api_key": "",
"api_base": "https://api.fish.audio/v1",
"fishaudio-tts-model": "",
"fishaudio-tts-character": "可莉",
"fishaudio-tts-reference-id": "",
"timeout": "20",
Expand Down Expand Up @@ -2678,6 +2679,11 @@
"type": "string",
"hint": "fishaudio TTS 的参考模型ID(可选)。如果填入此字段,将直接使用模型ID而不通过角色名称查询。例如:626bb6d3f3364c9cbc3aa6a67300a664。更多模型请访问:https://fish.audio/zh-CN/discovery,进入模型详情界面后可复制模型ID",
},
"fishaudio-tts-model": {
"description": "TTS 模型",
"type": "string",
"hint": "FishAudio TTS 引擎模型 ID,如 s1、s2-pro。留空则使用 API 默认模型。详见 https://fish.audio",
},
"whisper_hint": {
"description": "本地部署 Whisper 模型须知",
"type": "string",
Expand Down
5 changes: 4 additions & 1 deletion astrbot/core/provider/sources/fishaudio_tts_api_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class ServeTTSRequest(BaseModel):
normalize: bool = True
# 平衡模式将延迟减少到300毫秒,但可能会降低稳定性
latency: Literal["normal", "balanced"] = "normal"
# TTS 模型,如 s1、s2-pro 等。FishAudio API 要求请求中携带该字段
model: str = ""


@register_provider_adapter(
Expand Down Expand Up @@ -67,7 +69,7 @@ def __init__(
self.headers = {
"Authorization": f"Bearer {self.chosen_api_key}",
}
self.set_model(provider_config.get("model", ""))
self.set_model(provider_config.get("fishaudio-tts-model", ""))

async def _get_reference_id_by_character(self, character: str) -> str | None:
"""获取角色的reference_id
Expand Down Expand Up @@ -139,6 +141,7 @@ async def _generate_request(self, text: str) -> ServeTTSRequest:
text=text,
format="wav",
reference_id=reference_id,
model=self.get_model(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

如果用户在 WebUI 中将 fishaudio-tts-model 留空,self.get_model() 将返回空字符串 ""。这会导致向 Fish Audio API 发送 "model": "" 的请求,从而引发 API 错误(例如 400 或 422 错误),因为空字符串不是有效的模型 ID。为了支持“留空则使用默认模型”的设计,建议在 self.get_model() 为空时,默认使用 Fish Audio 的标准默认模型 "stable-v1"

Suggested change
model=self.get_model(),
model=self.get_model() or "stable-v1",

)

async def get_audio(self, text: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,10 @@
"description": "reference_id",
"hint": "Fishaudio TTS reference model ID (optional). If set, the model ID is used directly instead of looking up by role name. Example: 626bb6d3f3364c9cbc3aa6a67300a664. More models: https://fish.audio/zh-CN/discovery; open a model detail page to copy the model ID."
},
"fishaudio-tts-model": {
"description": "TTS Model",
"hint": "FishAudio TTS engine model ID, e.g. s1, s2-pro. Leave empty to use the API default model. See https://fish.audio"
},
"whisper_hint": {
"description": "Notes for local Whisper deployment",
"hint": "Before enabling, install the openai-whisper library (NVIDIA users download ~2GB mainly for torch and cuda; CPU users download ~1GB), and install ffmpeg. Otherwise STT will not work."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,10 @@
"description": "Coze API Key",
"hint": "ID модели Fishaudio; используется вместо имени роли."
},
"fishaudio-tts-model": {
"description": "Модель TTS",
"hint": "ID модели движка FishAudio TTS, например s1, s2-pro. Оставьте пустым для модели по умолчанию. См. https://fish.audio"
},
"whisper_hint": {
"description": "Заметки по локальному развертыванию Whisper",
"hint": "Перед включением установите openai-whisper и ffmpeg."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,10 @@
"description": "reference_id",
"hint": "fishaudio TTS 的参考模型ID(可选)。如果填入此字段,将直接使用模型ID而不通过角色名称查询。例如:626bb6d3f3364c9cbc3aa6a67300a664。更多模型请访问:https://fish.audio/zh-CN/discovery,进入模型详情界面后可复制模型ID"
},
"fishaudio-tts-model": {
"description": "TTS 模型",
"hint": "FishAudio TTS 引擎模型 ID,如 s1、s2-pro。留空则使用 API 默认模型。详见 https://fish.audio"
},
"whisper_hint": {
"description": "本地部署 Whisper 模型须知",
"hint": "启用前请 pip 安装 openai-whisper 库(N卡用户大约下载 2GB,主要是 torch 和 cuda,CPU 用户大约下载 1 GB),并且安装 ffmpeg。否则将无法正常转文字。"
Expand Down