fix(tts): 修复Android包可见性导致TTS未绑定问题,优化语音时序与引擎探测
This commit is contained in:
@@ -203,7 +203,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
const Divider(height: 1),
|
||||
SwitchListTile(
|
||||
title: const Text('真人语音播报', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
|
||||
subtitle: const Text('做完时自动播报“本次雾化吸入已全部完成,请及时用清水漱口并洗脸”', style: TextStyle(fontSize: 12)),
|
||||
subtitle: const Text('各阶段步骤语音提醒与完成时漱口洗脸指引(需开启媒体音量)', style: TextStyle(fontSize: 12)),
|
||||
value: _settings.enableVoicePrompt,
|
||||
activeTrackColor: const Color(0xFF2563EB),
|
||||
onChanged: (val) {
|
||||
@@ -213,19 +213,36 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 12),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: OutlinedButton.icon(
|
||||
onPressed: () {
|
||||
TtsService().speak('本次雾化吸入已全部完成,请及时用清水漱口并洗脸!');
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
visualDensity: VisualDensity.compact,
|
||||
side: const BorderSide(color: Color(0xFFBFDBFE)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
OutlinedButton.icon(
|
||||
onPressed: () async {
|
||||
final ok = await TtsService().speak('本次雾化吸入已全部完成,请及时用清水漱口并洗脸!');
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(ok ? '已发送语音播放请求,请确认手机媒体音量已开启' : '语音播放请求已发送,如未听到请检查系统TTS设置与媒体音量'),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
visualDensity: VisualDensity.compact,
|
||||
side: const BorderSide(color: Color(0xFFBFDBFE)),
|
||||
),
|
||||
icon: const Icon(Icons.volume_up, size: 16, color: Color(0xFF2563EB)),
|
||||
label: const Text('🔊 点击试听语音播报效果', style: TextStyle(fontSize: 12, color: Color(0xFF2563EB))),
|
||||
),
|
||||
icon: const Icon(Icons.volume_up, size: 16, color: Color(0xFF2563EB)),
|
||||
label: const Text('🔊 点击试听语音播报效果', style: TextStyle(fontSize: 12, color: Color(0xFF2563EB))),
|
||||
),
|
||||
if (TtsService().selectedEngine != null) ...[
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'当前语音引擎: ${TtsService().selectedEngine}',
|
||||
style: TextStyle(fontSize: 11, color: Colors.grey.shade500),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user