text_to_sound
Convert text to MP3 audio files for notifications, supporting multiple languages and adjustable speech speed.
Instructions
将一段文本转成mp3音频链接
Input Schema
TableJSON 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:8-24 (handler)The handler function for the 'text_to_sound' tool. It generates an MP3 audio URL from text using Baidu Fanyi TTS API, with parameters for language and speed. Includes inline schema definitions via Pydantic Field.@mcp.tool( title="文本转音频", description="将一段文本转成mp3音频链接", ) 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/__init__.py:23-23 (registration)Registers the tools from util.py (including text_to_sound) by calling util.add_tools(mcp) on the FastMCP instance.util.add_tools(mcp)
- mcp_notify/util.py:6-6 (registration)The add_tools function in util.py that defines and registers the text_to_sound tool using @mcp.tool() decorator.def add_tools(mcp: FastMCP):