# yangsenessa
## 基本信息
- Slug: `yangsenessa-mcp_voice_identify`
- Source: modelscope
- Publisher: @yangsenessa/mcp_voice_identify
- Categories: speech-processing / audio-processing
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@yangsenessa/mcp_voice_identify
## 简介
暂无描述。
## MCP Server 详情

# 语音识别MCP服务

该服务通过stdio和MCP模式提供语音识别和文本提取功能。

## 功能

- 从文件进行语音识别
- 从Base64编码数据进行语音识别
- 文本提取
- 支持stdio和MCP两种模式
- 结构化的语音识别结果
- 符合AIO协议的响应

## 项目结构

- `voice_service.py` - 核心服务实现
- `stdio_server.py` - stdio模式入口点
- `mcp_server.py` - MCP模式入口点
- `build.py` - 可执行文件构建脚本
- `build_exec.sh` - 构建执行脚本
- `test_*.sh` - 不同功能的测试脚本

## 安装

1. 克隆仓库：
bash
git clone https://github.com/AIO-2030/mcp_voice_identify.git
cd mcp_voice_identify


2. 安装依赖项：
bash
pip install -r requirements.txt


3. 在`.env`中设置环境变量：

API_URL=your_api_url
API_KEY=your_api_key


## 使用

### stdio 模式

1. 运行服务：
bash
python stdio_server.py


2. 通过标准输入发送JSON-RPC请求：
json
{
    "jsonrpc": "2.0",
    "method": "help",
    "params": {},
    "id": 1
}


3. 或者使用可执行文件：
bash
./dist/voice_stdio


### MCP 模式

1. 运行服务：
bash
python mcp_server.py


2. 或者使用可执行文件：
bash
./dist/voice_mcp


## 响应格式

该服务遵循AIO协议的响应格式。以下是不同响应类型的示例：

### 语音识别响应
json
{
    "jsonrpc": "2.0",
    "output": {
        "type": "voice",
        "message": "语音处理成功",
        "text": "test test test",
        "metadata": {
            "language": "en",
            "emotion": "unknown",
            "audio_type": "speech",
            "speaker": "woitn",
            "raw_text": "test test test"
        }
    },
    "id": 1
}


### 帮助信息响应
json
{
    "jsonrpc": "2.0",
    "result": {
        "type": "voice_service",
        "description": "此服务提供语音识别和文本提取服务",
        "author": "AIO-2030",
        "version": "1.0.0",
        "github": "https://github.com/AIO-2030/mcp_voice_identify",
        "transport": ["stdio"],
        "methods": [
            {
                "name": "help",
                "description": "显示帮助信息。"
            },
            {
                "name": "identify_voice",
                "description": "从文件识别语音",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "file_path": {
                            "type": "string",
                            "description": "语音文件路径"
                        }
                    },
                    "required": ["file_path"]
                }
            },
            {
                "name": "identify_voice_base64",
                "description": "从Base64编码数据识别语音",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "base64_data": {
                            "type": "string",
                            "description": "Base64编码的语音数据"
                        }
                    },
                    "required": ["base64_data"]
                }
            },
            {
                "name": "extract_text",
                "description": "提取文本",
                "inputSchema": {
                    "type": "object",
                    "properties": {
                        "text": {
                            "type": "string",
                            "description": "要提取的文本"
                        }
                    },
                    "required": ["text"]
                }
            }
        ]
    },
    "id": 1
}


### 错误响应
json
{
    "jsonrpc": "2.0",
    "output": {
        "type": "error",
        "message": "503 服务器错误：服务不可用",
        "error_code": 503
    },
    "id": 1
}### 响应字段

服务提供了三种类型的响应：

1. 语音识别响应（使用 `output` 字段）:
| 字段      | 描述                           | 示例值                 |
|-----------|---------------------------------|------------------------|
| type      | 响应类型                       | "voice"                |
| message   | 状态消息                       | "Voice processed successfully" |
| text      | 识别的文本内容                 | "test test test"       |
| metadata  | 额外信息                       | 请参见下文             |

2. 帮助信息响应（使用 `result` 字段）:
| 字段         | 描述                           | 示例值                 |
|---------------|---------------------------------|------------------------|
| type          | 服务类型                       | "voice_service"        |
| description   | 服务描述                       | "This service provides..." |
| author        | 服务作者                       | "AIO-2030"            |
| version       | 服务版本                       | "1.0.0"               |
| github        | GitHub 仓库 URL                | "https://github.com/..." |
| transport     | 支持的传输模式                 | ["stdio"]             |
| methods       | 可用方法                       | 请参见方法列表         |

3. 错误响应（使用 `output` 字段）:
| 字段       | 描述                           | 示例值                 |
|-------------|---------------------------------|------------------------|
| type        | 响应类型                       | "error"                |
| message     | 错误消息                       | "503 Server Error: Service Unavailable" |
| error_code  | HTTP 状态码                    | 503                   |

### 元数据字段

在语音识别响应中的 `metadata` 字段包含以下内容：

| 字段       | 描述                           | 示例值                 |
|-------------|---------------------------------|------------------------|
| language    | 语言代码                       | "en"                   |
| emotion     | 情感状态                       | "unknown"              |
| audio_type  | 音频类型                       | "speech"               |
| speaker     | 发言者标识符                   | "woitn"                |
| raw_text    | 原始识别文本                   | "test test test"       |

## 构建可执行文件

1. 使构建脚本可执行：
bash
chmod +x build_exec.sh


2. 构建 stdio 模式可执行文件：
bash
./build_exec.sh


3. 构建 MCP 模式可执行文件：
bash
./build_exec.sh mcp


生成的可执行文件位于：
- stdio 模式: `dist/voice_stdio`
- MCP 模式: `dist/voice_mcp`

## 测试

运行测试脚本：

bash
chmod +x test_*.sh
./test_help.sh
./test_voice_file.sh
./test_voice_base64.sh


## 许可证

此项目根据 MIT 许可证发布 - 详情请参阅 LICENSE 文件。

