Merge pull request #1 from leslie2046/list-voicer
feat: list voice
This commit was merged in pull request #1.
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
version: 0.0.1
|
version: 0.0.2
|
||||||
type: plugin
|
type: plugin
|
||||||
author: quicksandzn
|
author: quicksandzn
|
||||||
name: minimax_kit
|
name: minimax_kit
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ tools:
|
|||||||
- tools/music_generation.yaml
|
- tools/music_generation.yaml
|
||||||
- tools/voice_clone.yaml
|
- tools/voice_clone.yaml
|
||||||
- tools/video_generation.yaml
|
- tools/video_generation.yaml
|
||||||
|
- tools/list_voicers.yaml
|
||||||
extra:
|
extra:
|
||||||
python:
|
python:
|
||||||
source: provider/minimax.py
|
source: provider/minimax.py
|
||||||
@@ -163,3 +163,10 @@ class MiniMaxBaseTool:
|
|||||||
params={"GroupId": self.group_id, "purpose": purpose},
|
params={"GroupId": self.group_id, "purpose": purpose},
|
||||||
)
|
)
|
||||||
return response
|
return response
|
||||||
|
def get_voice(self, voice_type: str) -> requests.Response:
|
||||||
|
response = self._request(
|
||||||
|
"POST",
|
||||||
|
f"{API_ENDPOINT}/get_voice",
|
||||||
|
data={"voice_type": voice_type},
|
||||||
|
)
|
||||||
|
return response
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import json
|
||||||
|
from typing import Generator, Any
|
||||||
|
from dify_plugin import Tool
|
||||||
|
from dify_plugin.entities.tool import ToolInvokeMessage
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from tools.base import MiniMaxBaseTool
|
||||||
|
|
||||||
|
|
||||||
|
class ListVoicers(Tool):
|
||||||
|
def _invoke(self, tool_parameters: dict[str, Any]) -> Generator[ToolInvokeMessage, None, None]:
|
||||||
|
"""
|
||||||
|
List available models from Fish Audio
|
||||||
|
"""
|
||||||
|
api_key = self.runtime.credentials.get("api_key")
|
||||||
|
group_id = self.runtime.credentials.get("group_id")
|
||||||
|
minimax = MiniMaxBaseTool(api_key=api_key, group_id=group_id)
|
||||||
|
voice_type = tool_parameters.get("voice_type")
|
||||||
|
response = minimax.get_voice(
|
||||||
|
voice_type=voice_type
|
||||||
|
)
|
||||||
|
if response.status_code != 200:
|
||||||
|
yield self.create_text_message(
|
||||||
|
f"Get voice failed {response.status_code} {response.text}"
|
||||||
|
)
|
||||||
|
return
|
||||||
|
status_code = response.json().get("base_resp", {}).get("status_code", -1)
|
||||||
|
if status_code != 0:
|
||||||
|
yield self.create_text_message(f"Get voice failed {response.text}")
|
||||||
|
return
|
||||||
|
lines = []
|
||||||
|
i = 1
|
||||||
|
|
||||||
|
# 遍历三个类别
|
||||||
|
for category in ["system_voice", "voice_cloning", "voice_generation"]:
|
||||||
|
items = response.json().get(category, [])
|
||||||
|
if not isinstance(items, list):
|
||||||
|
continue
|
||||||
|
lines.append(f"=== Category: {category} ===")
|
||||||
|
for item in items:
|
||||||
|
voice_id = item.get("voice_id", "")
|
||||||
|
voice_name = item.get("voice_name", "无")
|
||||||
|
desc_list = item.get("description", [])
|
||||||
|
desc = ";".join(desc_list) if desc_list else "无"
|
||||||
|
created_time = item.get("created_time", "")
|
||||||
|
|
||||||
|
lines.append(
|
||||||
|
f"{i}.ID: {voice_id}\n"
|
||||||
|
f" Voice Name: {voice_name}\n"
|
||||||
|
f" Description: {desc}\n"
|
||||||
|
f" Created_time: {created_time}\n"
|
||||||
|
)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
yield self.create_text_message("\n\n".join(lines))
|
||||||
|
yield self.create_json_message(response.json())
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
identity:
|
||||||
|
name: list_voicers
|
||||||
|
author: langgenius
|
||||||
|
label:
|
||||||
|
en_US: List all voicers
|
||||||
|
zh_Hans: 列出发音人
|
||||||
|
description:
|
||||||
|
human:
|
||||||
|
en_US: List all voicers
|
||||||
|
zh_Hans: 列出发音人
|
||||||
|
llm: A tool to list all voicers
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
- name: voice_type
|
||||||
|
type: select
|
||||||
|
required: true
|
||||||
|
default: all
|
||||||
|
options:
|
||||||
|
- value: all
|
||||||
|
label:
|
||||||
|
en_US: All
|
||||||
|
zh_Hans: 所有
|
||||||
|
- value: system
|
||||||
|
label:
|
||||||
|
en_US: System
|
||||||
|
zh_Hans: 系统音色
|
||||||
|
- value: voice_cloning
|
||||||
|
label:
|
||||||
|
en_US: Voice cloning voicers
|
||||||
|
zh_Hans: 快速复刻的音色
|
||||||
|
- value: voice_generation
|
||||||
|
label:
|
||||||
|
en_US: Text generation voicers
|
||||||
|
zh_Hans: 文生音色接口生成的音色
|
||||||
|
label:
|
||||||
|
en_US: Voicer type
|
||||||
|
zh_Hans: 音色类型
|
||||||
|
human_description:
|
||||||
|
en_US: Voicer type
|
||||||
|
zh_Hans: 音色类型
|
||||||
|
llm_description: Voicer type to list.
|
||||||
|
form: form
|
||||||
|
|
||||||
|
extra:
|
||||||
|
python:
|
||||||
|
source: tools/list_voicers.py
|
||||||
Reference in New Issue
Block a user