Files
operating-room-monitor-server/web/voice-confirmation/README.md
2026-04-28 10:41:48 +08:00

37 lines
2.1 KiB
Markdown
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.
# 手术室耗材语音确认(浏览器端)
与 FastAPI **分宿部署**的纯静态页面HTML + JavaScript + [Tailwind CSS](https://tailwindcss.com) CDN配置 **服务端 Base URL****本机语音终端 ID** 即可使用,协议与 [`docs/客户端手术通信接口说明.md`](../../docs/客户端手术通信接口说明.md) 一致WebSocket 收 `voice_assignment` / `voice_pending` / `voice_pending_empty`HTTP `POST .../resolve` 上传 WAV
## 本地预览
勿使用 `file://` 打开(麦克风与跨域行为异常)。在仓库根目录先执行 `uv sync --group dev`**livereload** 在 dev 组中)。然后:
```bash
chmod +x start_voice_confirmation_web.sh # 仅首次
./start_voice_confirmation_web.sh # 默认 8080编辑 HTML/JS 后浏览器自动刷新
# 若不需要热重载(仅 stdlib 静态服务):
./start_voice_confirmation_web.sh --plain 8080
```
Windows`start_voice_confirmation_web.bat`;无热重载时首参 `--plain` 再跟端口。亦可:
```bash
uv run --group dev python scripts/dev_static_livereload.py --root web/voice-confirmation -p 8080
```
浏览器访问 `http://127.0.0.1:8080`(或所选端口),将 **Base URL** 指向监控 API`http://127.0.0.1:38080`)。
## 生产部署
- 将本目录原样部署到任意静态托管Nginx、对象存储、CDN 等)。
- **HTTPS**:非 localhost 下浏览器通常要求安全上下文才允许麦克风API 须使用 **https****wss**,避免混合内容被拦截。
- **CORS**:后端需对浏览器 `fetch` 放行;默认可开启环境变量 **`DEMO_CORS_ENABLED=true`**,并将 **`DEMO_CORS_ORIGINS`** 设为静态页来源(或联调期 `*`,见 [`main.py`](../../main.py))。
## 与 `scripts/demo_client` 的关系
本目录与 [`scripts/demo_client/`](../../scripts/demo_client/) **相互独立**Demo 含 HTTP 轮询待确认等联调能力;本页与官方语音确认语义一致,**不轮询** `GET .../pending-confirmation`
## 推荐浏览器
录音与 `AudioContext` 行为以 **Chrome / Edge 新版** 为优先验证目标。