一个基于Python的服务器,提供对Whissle API端点的访问,用于语音转文字、说话人识别、翻译和文本摘要。
克隆仓库:
git clone <repository-url>
cd whissle_mcp
创建并激活虚拟环境:
python -m venv venv
source venv/bin/activate # 在Windows上使用:venv\Scripts\activate
安装所需包:
pip install -e .
设置环境变量:
在项目根目录创建一个.env文件,内容如下:
WHISSLE_AUTH_TOKEN=insert_auth_token_here # 替换为你的实际Whissle API令牌
WHISSLE_MCP_BASE_PATH=/path/to/your/base/directory
⚠️ 重要:切勿将实际令牌提交到仓库。.env文件被包含在.gitignore中以防止意外提交。
配置Claude集成:
复制claude_config.example.json到claude_config.json并更新路径:
{
"mcpServers": {
"Whissle": {
"command": "/path/to/your/venv/bin/python",
"args": [
"/path/to/whissle_mcp/server.py"
],
"env": {
"WHISSLE_AUTH_TOKEN": "insert_auth_token_here"
}
}
}
}
/path/to/your/venv/bin/python替换为虚拟环境中Python解释器的实际路径/path/to/whissle_mcp/server.py替换为你server.py文件的实际路径WHISSLE_AUTH_TOKEN:你的Whissle API认证令牌(必需)
.env文件中安全存储它WHISSLE_MCP_BASE_PATH:文件操作的基本目录(可选,默认为用户的桌面)服务器支持以下音频格式:
使用Whissle API将语音转换为文本。
response = speech_to_text(
audio_file_path="path/to/audio.wav",
model_name="en-NER", # 默认模型
timestamps=True, # 包含单词时间戳
boosted_lm_words=["特定", "术语"], # 在识别中提升的词语
boosted_lm_score=80 # 提升词语的得分(0-100)
)
将语音转换为文本,并识别说话人。
response = diarize_speech(
audio_file_path="path/to/audio.wav",
model_name="en-NER", # 默认模型
max_speakers=2, # 要识别的最大说话人数
boosted_lm_words=["特定", "术语"],
boosted_lm_score=80
)
将文本从一种语言翻译成另一种语言。
response = translate_text(
text="你好,世界!",
source_language="zh",
target_language="es"
)
使用LLM模型对文本进行摘要。
response = summarize_text(
content="需要摘要的长文本...",
model_name="openai", # 默认模型
instruction="提供简要摘要" # 可选
)
列出所有可用的ASR模型及其能力。
response = list_asr_models()
{
"transcript": "转录的文字",
"duration_seconds": 10.5,
"language_code": "zh",
"timestamps": [
{
"word": "你好",
"startTime": 0,
"endTime": 100,
"confidence": 0.95
}
],
"diarize_output": [
{
"text": "转录的文字",
"speaker_id": 1,
"start_timestamp": 0,
"end_timestamp": 10.5
}
]
}
{
"type": "text",
"text": "翻译:\n翻译后的文本"
}
{
"type": "text",
"text": "摘要:\n摘要后的文本"
}
{
"error": "错误信息"
}
服务器包括强大的错误处理机制:
常见错误类型:
启动服务器:
mcp serve
服务器将在默认的MCP端口(通常是8000)上可用。
提供了一个测试脚本来验证所有工具的功能:
python test_whissle.py
测试脚本将:
对于问题或疑问,请:
[在此添加您的许可信息]