43 lines
981 B
Markdown
43 lines
981 B
Markdown
|
|
# 📢 读题功能说明
|
|||
|
|
|
|||
|
|
## 工作原理
|
|||
|
|
|
|||
|
|
App 使用 **WebView 内置的浏览器语音合成 API**(Web Speech API)来实现读题功能。
|
|||
|
|
|
|||
|
|
这种方式的优点:
|
|||
|
|
- ✅ 不需要手机安装额外的 TTS 引擎
|
|||
|
|
- ✅ 与 PC 浏览器使用相同的代码
|
|||
|
|
- ✅ 简单可靠,无需复杂配置
|
|||
|
|
|
|||
|
|
## 兼容性
|
|||
|
|
|
|||
|
|
- Android 5.0+ 的 WebView 支持 Web Speech API
|
|||
|
|
- 大多数现代手机都支持
|
|||
|
|
|
|||
|
|
## 使用方法
|
|||
|
|
|
|||
|
|
1. 进入测评/问卷答题页面
|
|||
|
|
2. 点击题目旁边的朗读按钮 🔊
|
|||
|
|
3. 系统会自动朗读题目内容
|
|||
|
|
|
|||
|
|
## 如果没有声音
|
|||
|
|
|
|||
|
|
1. 检查手机音量(媒体音量,不是铃声音量)
|
|||
|
|
2. 确保不是静音模式
|
|||
|
|
3. 重启 App 重试
|
|||
|
|
|
|||
|
|
## 技术说明
|
|||
|
|
|
|||
|
|
前端使用 `window.speechSynthesis` API:
|
|||
|
|
```javascript
|
|||
|
|
const utterance = new SpeechSynthesisUtterance(text);
|
|||
|
|
utterance.lang = 'zh-CN';
|
|||
|
|
window.speechSynthesis.speak(utterance);
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
WebView 配置:
|
|||
|
|
```java
|
|||
|
|
// 允许媒体自动播放
|
|||
|
|
settings.setMediaPlaybackRequiresUserGesture(false);
|
|||
|
|
```
|