You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
5.4 KiB
171 lines
5.4 KiB
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import '../controllers/profile_controller.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import '../../../data/services/volcano_tts_service.dart';
|
|
import '../../../core/widgets/common_bottom_nav.dart';
|
|
import '../../speech_demo/speech_demo_page.dart';
|
|
import '../../../modules/microsoft_tts_example.dart';
|
|
import '../../../modules/microsoft_tts_continuous_example.dart';
|
|
import '../../../data/services/microsoft_tts_service.dart';
|
|
|
|
class ProfileView extends GetView<ProfileController> {
|
|
const ProfileView({Key? key}) : super(key: key);
|
|
|
|
Widget _buildMenuItem({
|
|
required String title,
|
|
required IconData icon,
|
|
String? subtitle,
|
|
required VoidCallback onTap,
|
|
}) {
|
|
return ListTile(
|
|
leading: Icon(icon, size: 24.sp, color: Colors.grey[700]),
|
|
title: Text(
|
|
title,
|
|
style: TextStyle(
|
|
fontSize: 16.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
subtitle: subtitle != null
|
|
? Text(
|
|
subtitle,
|
|
style: TextStyle(
|
|
fontSize: 14.sp,
|
|
color: Colors.grey[600],
|
|
),
|
|
)
|
|
: null,
|
|
trailing: Icon(
|
|
Icons.chevron_right,
|
|
size: 24.sp,
|
|
color: Colors.grey[400],
|
|
),
|
|
onTap: onTap,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
elevation: 0,
|
|
title: Text(
|
|
'设置',
|
|
style: TextStyle(
|
|
fontSize: 17.sp,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
),
|
|
body: ListView(
|
|
children: [
|
|
SizedBox(height: 12.h),
|
|
_buildMenuItem(
|
|
title: '测试语音合成',
|
|
icon: Icons.record_voice_over,
|
|
subtitle: '测试微软语音TTS功能',
|
|
onTap: () async {
|
|
try {
|
|
final tts = Get.find<MicrosoftTtsService>();
|
|
|
|
// 检查TTS服务状态
|
|
print('TTS服务状态: enabled=${tts.isEnabled.value}');
|
|
|
|
// 确保TTS已启用
|
|
if (!tts.isEnabled.value) {
|
|
print('TTS服务未启用,正在启用...');
|
|
tts.isEnabled.value = true;
|
|
}
|
|
|
|
// 先停止之前的播放
|
|
await tts.stop();
|
|
|
|
print('开始播放连续测试语音...');
|
|
// 连续播放多段文本
|
|
await tts.speak('你好,这是第一段测试语音。');
|
|
await tts.speak('这是第二段语音,用于测试连续播放功能。');
|
|
await tts.speak('现在是第三段语音,测试火山语音的连续合成能力。');
|
|
await tts.speak('最后一段测试语音,感谢您的收听。');
|
|
|
|
Get.snackbar(
|
|
'提示',
|
|
'正在播放连续测试语音',
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
duration: const Duration(seconds: 2),
|
|
);
|
|
} catch (e, stack) {
|
|
print('TTS测试失败: $e');
|
|
print('错误堆栈: $stack');
|
|
Get.snackbar(
|
|
'错误',
|
|
'TTS服务错误: $e',
|
|
snackPosition: SnackPosition.BOTTOM,
|
|
backgroundColor: Colors.red.withOpacity(0.1),
|
|
colorText: Colors.red,
|
|
duration: const Duration(seconds: 3),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
const Divider(),
|
|
_buildMenuItem(
|
|
title: '微软语音合成测试',
|
|
icon: Icons.record_voice_over_outlined,
|
|
subtitle: '测试微软 Azure TTS 功能',
|
|
onTap: () {
|
|
Get.to(() => const MicrosoftTtsExample());
|
|
},
|
|
),
|
|
const Divider(),
|
|
_buildMenuItem(
|
|
title: '微软连续语音合成测试',
|
|
icon: Icons.queue_music_outlined,
|
|
subtitle: '测试微软 Azure TTS 连续语音功能',
|
|
onTap: () {
|
|
Get.to(() => const MicrosoftTtsContinuousExample());
|
|
},
|
|
),
|
|
const Divider(),
|
|
_buildMenuItem(
|
|
title: '语音识别测试',
|
|
icon: Icons.mic,
|
|
subtitle: '测试语音识别功能',
|
|
onTap: () {
|
|
Get.to(() => const SpeechDemoPage());
|
|
},
|
|
),
|
|
const Divider(),
|
|
_buildMenuItem(
|
|
title: '关于',
|
|
icon: Icons.info_outline,
|
|
onTap: () {
|
|
// TODO: 实现关于页面
|
|
},
|
|
),
|
|
const Divider(),
|
|
_buildMenuItem(
|
|
title: '检查更新',
|
|
icon: Icons.system_update,
|
|
onTap: () {
|
|
// TODO: 实现检查更新
|
|
},
|
|
),
|
|
const Divider(),
|
|
_buildMenuItem(
|
|
title: '清除缓存',
|
|
icon: Icons.cleaning_services_outlined,
|
|
onTap: () {
|
|
// TODO: 实现清除缓存
|
|
},
|
|
),
|
|
],
|
|
),
|
|
bottomNavigationBar: const CommonBottomNav(currentIndex: 2),
|
|
);
|
|
}
|
|
}
|