本帖最后由 wudalang123 于 2025-6-11 13:31 编辑
bonwe95 发表于 2025-6-10 19:36
并播报语音就更完美了
三步接入语音播报
安装语音引擎(系统级支持)
[Bash shell] 纯文本查看 复制代码 # 安装微软语音库(Win10/11通用)
powershell -Command "Add-WindowsCapability -Online -Name Language.TextToSpeech~~~zh-CN~0.0.1.0"
创建语音触发脚本 speak.bat
[Bash shell] 纯文本查看 复制代码 @echo off
:: 参数1=播报内容
set text=%1
powershell -Command "Add-Type -AssemblyName System.Speech; $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; $speak.Speak('%text%');"
修改叫号逻辑(Hook系统事件)在 CallNum_Server.exe 同级目录创建 call_hook.js:[JavaScript] 纯文本查看 复制代码 // 监听叫号按钮点击
setInterval(() => {
const calledItem = document.querySelector('.list-group-item:not(.bg-light)');
if (calledItem && !calledItem.dataset.spoken) {
const phone = calledItem.querySelector('.phone').innerText;
const num = calledItem.querySelector('.badge').innerText;
// 触发语音播报
fetch(`/speak?text=请${num}号顾客到${phone.slice(-4)}号窗口`);
calledItem.dataset.spoken = true;
}
}, 1000); 注入脚本到Web页面创建启动器 start_with_voice.bat:[Bash shell] 纯文本查看 复制代码 @echo off
start CallNum_Server.exe
timeout /t 3
# 自动打开浏览器并注入脚本
start "" "http://localhost:888" && timeout /t 2 && (
echo 正在注入语音脚本...
curl -X POST -H "Content-Type: application/json" -d "{\"script\":\"$(type call_hook.js)\"}" http://localhost:888/inject
)
|