文本转音频
text_to_soundConvert any text into an MP3 audio link. Choose language and speed to generate spoken audio.
Instructions
将一段文本转成mp3音频链接
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 文本内容 | |
| lang | No | 目标语言,支持: en/zh/cte(粤语)/ara/de/fra/kor/pt/ru/spa/th, 建议根据文本内容选择 | en |
| speed | No | 语速,默认7 |
Implementation Reference
- mcp_notify/util.py:12-24 (handler)The handler function for the 'text_to_sound' tool. It takes text, lang (default 'en'), and speed (default 7), and returns a Baidu TTS URL.
def text_to_sound( text: str = Field(description="文本内容"), lang: str = Field("en", description="目标语言,支持: en/zh/cte(粤语)/ara/de/fra/kor/pt/ru/spa/th, 建议根据文本内容选择"), speed: int = Field(7, description="语速,默认7"), ): if not text: return "" return 'https://fanyi.baidu.com/gettts?' + urlencode({ 'lan': lang, 'spd': speed, 'text': text, 'source': 'web', }) - mcp_notify/util.py:8-11 (registration)The @mcp.tool decorator registering 'text_to_sound' as an MCP tool with title '文本转音频' and description '将一段文本转成mp3音频链接'.
@mcp.tool( title="文本转音频", description="将一段文本转成mp3音频链接", ) - mcp_notify/__init__.py:18-23 (registration)The main registration point calling util.add_tools(mcp) which registers all util tools including text_to_sound.
mcp = FastMCP(name="mcp-notify", version="0.1.11") wework.add_tools(mcp) tgbot.add_tools(mcp) other.add_tools(mcp) hass.add_tools(mcp) util.add_tools(mcp)