文本转音频
text_to_soundConverts text into an MP3 audio link. Supports multiple languages and adjustable speech speed for use in notifications.
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 actual handler function for the 'text_to_sound' tool. Takes text, lang, and speed parameters, builds a Baidu TTS URL using urlencode, and returns the mp3 audio link.
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:13-16 (schema)Input schema/validation using Pydantic Field for the text, lang, and speed parameters of the text_to_sound tool.
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"), ): - mcp_notify/util.py:6-11 (registration)The add_tools function that registers text_to_sound (and potentially other tools) onto the FastMCP server via the @mcp.tool decorator.
def add_tools(mcp: FastMCP, logger=None): @mcp.tool( title="文本转音频", description="将一段文本转成mp3音频链接", ) - mcp_notify/__init__.py:23-23 (registration)The import and call to util.add_tools(mcp) which triggers registration of the text_to_sound tool.
util.add_tools(mcp)