Commit 37b78a156574d282e2faf00fdace9de421818ce4
1 parent
c948a9ea
feat:添加录音插件
Showing
4 changed files
with
36 additions
and
9 deletions
ios/Runner/XSMessageMehtodChannel.swift
... | ... | @@ -65,6 +65,24 @@ class XSMessageMehtodChannel: NSObject,SSOralEvaluatingManagerDelegate { |
65 | 65 | SSOralEvaluatingManager.share().startEvaluateOral(with: config) |
66 | 66 | } |
67 | 67 | |
68 | + //开始评测(本地音频文件) | |
69 | + func evaluateLocalVoice(dict:Dictionary<String, Any>) { | |
70 | + let text = dict["word"] as? String ?? "" | |
71 | + let type = dict["type"] as? String ?? "0" | |
72 | + let userId = dict["userId"] as? String ?? "guest" | |
73 | + let voicePath = dict["voicePath"] as? String ?? "" | |
74 | + let config = SSOralEvaluatingConfig() | |
75 | + config.oralContent = text | |
76 | + if (type == "0") { | |
77 | + config.oralType = .word | |
78 | + } else { | |
79 | + config.oralType = .sentence | |
80 | + } | |
81 | + config.oralType = .kidSent | |
82 | + config.userId = userId | |
83 | + SSOralEvaluatingManager.share().startEvaluateOral(withWavPath: voicePath, config: config) | |
84 | + } | |
85 | + | |
68 | 86 | func handle(_ call: FlutterMethodCall,_ result: @escaping FlutterResult) { |
69 | 87 | if (call.method == "initVoiceSdk") { |
70 | 88 | self.setEvaluateConfig(dict:call.arguments as! Dictionary<String, Any>) |
... | ... | @@ -75,6 +93,11 @@ class XSMessageMehtodChannel: NSObject,SSOralEvaluatingManagerDelegate { |
75 | 93 | return |
76 | 94 | } |
77 | 95 | |
96 | + if (call.method == "starLocalVoice") { | |
97 | + self.evaluateLocalVoice(dict: call.arguments as! Dictionary<String, Any>) | |
98 | + return | |
99 | + } | |
100 | + | |
78 | 101 | if (call.method == "stopVoice") { |
79 | 102 | SSOralEvaluatingManager.share().stopEvaluate(); |
80 | 103 | return | ... | ... |
lib/pages/repeatafter/widgets/repeat_after_item.dart
... | ... | @@ -19,12 +19,13 @@ class RepeatAfterItem extends StatelessWidget { |
19 | 19 | ), |
20 | 20 | child: GestureDetector( |
21 | 21 | onTap: (){ |
22 | - if (entity != null) { | |
23 | - // if (!entity!.lock!) { | |
24 | - // tapEvent?.call(); | |
25 | - // } | |
26 | - tapEvent?.call(); | |
27 | - } | |
22 | + ///todo 暂时注释调,测试用 | |
23 | + // if (entity != null) { | |
24 | + // if (!entity!.lock!) { | |
25 | + // tapEvent?.call(); | |
26 | + // } | |
27 | + // } | |
28 | + tapEvent?.call(); | |
28 | 29 | }, |
29 | 30 | child: Stack( |
30 | 31 | children: [ | ... | ... |
lib/pages/repeataftercontent/bloc/repeat_after_content_bloc.dart
... | ... | @@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart'; |
3 | 3 | import 'package:flutter/services.dart'; |
4 | 4 | import 'package:flutter_bloc/flutter_bloc.dart'; |
5 | 5 | import 'package:wow_english/common/request/dao/listen_dao.dart'; |
6 | - | |
7 | 6 | import '../../../common/request/exception.dart'; |
8 | 7 | import '../../../models/read_content_entity.dart'; |
9 | 8 | import '../../../utils/loading.dart'; |
... | ... | @@ -196,8 +195,8 @@ class RepeatAfterContentBloc extends Bloc<RepeatAfterContentEvent, RepeatAfterCo |
196 | 195 | void _voiceXsResult(XSVoiceResultEvent event,Emitter<RepeatAfterContentState> emitter) async { |
197 | 196 | final Map args = event.message as Map; |
198 | 197 | final result = args['result'] as Map; |
199 | - final overall = result['overall'].toString()??''; | |
200 | - final audioUrl = args['audioUrl'].toString()??''; | |
198 | + final overall = result['overall'].toString(); | |
199 | + final audioUrl = args['audioUrl'].toString(); | |
201 | 200 | _voiceTestResult = {'overall':overall,'audioUrl':audioUrl}; |
202 | 201 | emitter(XSVoiceTestState()); |
203 | 202 | } | ... | ... |
pubspec.yaml
... | ... | @@ -93,6 +93,10 @@ dependencies: |
93 | 93 | responsive_framework: ^1.0.0 |
94 | 94 | # 音频播放 https://pub.dev/packages/audioplayers |
95 | 95 | audioplayers: ^4.1.0 |
96 | + # 语音录制 https://pub.dev/packages/flutter_sound | |
97 | + flutter_sound: ^9.2.13 | |
98 | + # 文件管理 https://pub.dev/packages/path_provider | |
99 | + path_provider: ^2.0.15 | |
96 | 100 | |
97 | 101 | dev_dependencies: |
98 | 102 | build_runner: ^2.4.4 | ... | ... |