guoyu/log/配置远程Whisper指南.txt
2025-12-11 23:28:07 +08:00

186 lines
4.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

====================================
配置远程 Whisper 服务指南
====================================
【第一步】测试远程 Whisper 连接
====================================
1. 获取 Whisper 服务器信息
询问服务器管理员:
- 服务器 IP 地址例如192.168.1.100
- Whisper 端口默认5001
2. 修改测试脚本
编辑文件测试远程Whisper.ps1
找到这两行:
$whisperHost = "YOUR_SERVER_IP"
$whisperPort = 5001
改为实际值,例如:
$whisperHost = "192.168.1.100"
$whisperPort = 5001
3. 运行测试
右键点击 "测试远程Whisper.ps1" → 使用 PowerShell 运行
或在 PowerShell 中:
powershell -ExecutionPolicy Bypass -File .\测试远程Whisper.ps1
4. 确认测试通过
应该看到:
✓ 服务器可达
✓ 端口可访问
✓ 健康检查通过
✓ 接口地址已确认
【第二步】修改 Java 应用配置
====================================
文件位置:
Study-Vue-redis\ry-study-system\src\main\java\com\ddnai\system\service\voice\LocalWhisperService.java
1. 找到第 36 行:
private static final String WHISPER_URL = "http://localhost:5001";
2. 修改为远程服务器地址:
private static final String WHISPER_URL = "http://192.168.1.100:5001";
(将 192.168.1.100 替换为实际的服务器 IP
3. 保存文件
【第三步】重新编译 Java 应用
====================================
1. 打开 PowerShell/CMD进入项目目录
cd C:\Users\Administrator\Desktop\Project\ry_study\Study-Vue-redis
2. 停止正在运行的 Java 应用(如果有)
找到 Java 进程并结束
3. 重新编译:
mvn clean package -DskipTests
4. 启动应用:
java -jar ry-study-admin\target\ry-study-admin.jar
5. 查看启动日志,确认 Whisper 服务连接状态
【第四步】验证配置
====================================
1. 浏览器访问测试接口:
http://localhost:8080/test/whisper/check
2. 预期响应(成功):
{
"code": 200,
"msg": "连接成功",
"data": {
"injected": true,
"available": true,
"status": "运行中",
"serviceInfo": "本地Whisper服务 (URL: http://192.168.1.100:5001, 状态: 运行中✅)"
}
}
3. 查看详细信息:
http://localhost:8080/test/whisper/info
【第五步】测试语音识别
====================================
方式1使用测试接口浏览器 + Postman
POST http://localhost:8080/test/whisper/recognize
上传参数file = test.mp3
方式2使用 curl 命令
curl -X POST http://localhost:8080/test/whisper/recognize -F "file=@test.mp3"
方式3在 APP 中测试
1. 启动 APP
2. 进入"语音测评"页面
3. 选择测评内容
4. 录音并提交
5. 查看识别结果和评分
【常见问题】
====================================
问题1连接超时
原因:
- 服务器防火墙阻止了端口
- Whisper 配置的监听地址错误(只监听 127.0.0.1
- 网络不通
解决:
1. 在服务器上开放端口:
# Windows 服务器
netsh advfirewall firewall add rule name="Whisper" dir=in action=allow protocol=TCP localport=5001
# Linux 服务器
firewall-cmd --add-port=5001/tcp --permanent
firewall-cmd --reload
2. 检查 Whisper 配置,确保监听 0.0.0.0
app.run(host='0.0.0.0', port=5001)
问题2连接被拒绝
原因:
- Whisper 服务未启动
- 端口配置错误
解决:
1. 登录服务器,检查 Whisper 是否运行:
netstat -ano | findstr 5001 (Windows)
lsof -i:5001 (Linux)
2. 启动 Whisper 服务:
cd <whisper_directory>
python app.py
问题3Java 应用无法连接
原因:
- 配置未生效(未重新编译)
- 目标服务器 IP 错误
解决:
1. 确认 LocalWhisperService.java 已修改
2. 确认已重新编译mvn clean package
3. 确认已重启 Java 应用
4. 检查日志中的 Whisper URL
【快速测试命令】
====================================
# 1. 测试远程 Whisper在你的电脑
curl http://192.168.1.100:5001/health
# 2. 测试识别(在你的电脑)
curl -X POST http://192.168.1.100:5001/recognize -F "file=@test.mp3" -F "language=zh"
# 3. 测试 Java 连接(在你的电脑)
curl http://localhost:8080/test/whisper/check
# 4. 在服务器上检查 Whisper
netstat -ano | findstr 5001
【需要的服务器信息】
====================================
请向服务器管理员索取:
1. Whisper 服务器 IP 地址______________
2. Whisper 服务端口______________默认 5001
3. 网络访问权限:是否已开放端口
4. Whisper 运行状态:是否已启动并正常运行
====================================