Explorar o código

添加评测类型维度

hwh97 %!s(int64=6) %!d(string=hai) anos
pai
achega
95c7cd0078

+ 1 - 0
.idea/libraries/Dart_SDK.xml

@@ -18,6 +18,7 @@
       <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/mirrors" />
       <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/svg" />
       <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/typed_data" />
+      <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/wasm" />
       <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/web_audio" />
       <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/web_gl" />
       <root url="file://C:/flutter/flutter/bin/cache/dart-sdk/lib/web_sql" />

+ 55 - 18
.idea/workspace.xml

@@ -2,11 +2,17 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="91fb8cbe-3946-4eca-a4cf-05dab52b73c6" name="Default Changelist" comment="">
-      <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/libraries/Dart_SDK.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Dart_SDK.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/.idea/caches/build_file_checksums.ser" beforeDir="false" afterPath="$PROJECT_DIR$/android/.idea/caches/build_file_checksums.ser" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/SpeechPlugin.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/SpeechPlugin.kt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/FinalResult.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/FinalResult.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/Result.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/Result.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/XmlResultParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/XmlResultParser.java" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/util/AudioEvaluatorUtil.kt" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/kotlin/cn/i2edu/speech_plugin/util/AudioEvaluatorUtil.kt" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/lib/speech_plugin.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/speech_plugin.dart" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/speech_plugin.iml" beforeDir="false" afterPath="$PROJECT_DIR$/speech_plugin.iml" afterDir="false" />
     </list>
     <ignored path="$PROJECT_DIR$/.dart_tool/" />
     <ignored path="$PROJECT_DIR$/.idea/" />
@@ -30,8 +36,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/lib/speech_plugin.dart">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="187">
-              <caret line="45" column="19" selection-start-line="45" selection-start-column="7" selection-end-line="45" selection-end-column="19" />
+            <state relative-caret-position="352">
+              <caret line="18" column="19" lean-forward="true" selection-start-line="18" selection-start-column="19" selection-end-line="18" selection-end-column="19" />
             </state>
           </provider>
         </entry>
@@ -39,7 +45,7 @@
       <file pinned="false" current-in-tab="false">
         <entry file="file://$PROJECT_DIR$/.gitignore">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="140">
+            <state relative-caret-position="154">
               <caret line="7" selection-start-line="7" selection-end-line="7" />
             </state>
           </provider>
@@ -47,6 +53,11 @@
       </file>
     </leaf>
   </component>
+  <component name="FindInProjectRecents">
+    <findStrings>
+      <find>invokeMethod</find>
+    </findStrings>
+  </component>
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
@@ -58,10 +69,8 @@
     </option>
   </component>
   <component name="ProjectFrameBounds" extendedState="6">
-    <option name="x" value="522" />
-    <option name="y" value="28" />
-    <option name="width" value="1346" />
-    <option name="height" value="955" />
+    <option name="width" value="1440" />
+    <option name="height" value="900" />
   </component>
   <component name="ProjectLevelVcsManager" settingsEditedManually="true" />
   <component name="ProjectView">
@@ -69,8 +78,7 @@
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
-      <pane id="PackagesPane" />
-      <pane id="AndroidView" />
+      <pane id="Scope" />
       <pane id="ProjectPane">
         <subPane>
           <expand>
@@ -87,12 +95,25 @@
               <item name="speech_plugin" type="b2602c69:ProjectViewProjectNode" />
               <item name="speech_plugin" type="462c0819:PsiDirectoryNode" />
               <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="build" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="speech_plugin" type="b2602c69:ProjectViewProjectNode" />
+              <item name="speech_plugin" type="462c0819:PsiDirectoryNode" />
+              <item name="android" type="462c0819:PsiDirectoryNode" />
+              <item name="wrapper" type="462c0819:PsiDirectoryNode" />
+            </path>
+            <path>
+              <item name="speech_plugin" type="b2602c69:ProjectViewProjectNode" />
+              <item name="speech_plugin" type="462c0819:PsiDirectoryNode" />
+              <item name="android" type="462c0819:PsiDirectoryNode" />
+              <item name="libs" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
               <item name="speech_plugin" type="b2602c69:ProjectViewProjectNode" />
               <item name="speech_plugin" type="462c0819:PsiDirectoryNode" />
-              <item name="ios" type="462c0819:PsiDirectoryNode" />
+              <item name="android" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
               <item name="speech_plugin" type="b2602c69:ProjectViewProjectNode" />
@@ -107,7 +128,8 @@
           <select />
         </subPane>
       </pane>
-      <pane id="Scope" />
+      <pane id="PackagesPane" />
+      <pane id="AndroidView" />
     </panes>
   </component>
   <component name="PropertiesComponent">
@@ -144,8 +166,9 @@
   </component>
   <component name="ToolWindowManager">
     <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
+    <editor active="true" />
     <layout>
-      <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.14658849" />
+      <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.14658849" />
       <window_info id="Captures" order="1" side_tool="true" />
       <window_info id="Structure" order="2" side_tool="true" />
       <window_info id="Image Layers" order="3" />
@@ -155,12 +178,12 @@
       <window_info id="Capture Tool" order="7" />
       <window_info id="Favorites" order="8" side_tool="true" />
       <window_info anchor="bottom" id="Dart Analysis" order="0" weight="0.32936078" />
-      <window_info anchor="bottom" id="Run" order="1" visible="true" weight="0.3299435" />
+      <window_info anchor="bottom" id="Run" order="1" weight="0.3299435" />
       <window_info anchor="bottom" id="TODO" order="2" />
       <window_info anchor="bottom" id="Android Profiler" order="3" show_stripe_button="false" />
       <window_info anchor="bottom" id="Logcat" order="4" />
       <window_info anchor="bottom" id="Debug" order="5" />
-      <window_info anchor="bottom" id="Terminal" order="6" />
+      <window_info active="true" anchor="bottom" id="Terminal" order="6" visible="true" weight="0.329718" />
       <window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
       <window_info anchor="bottom" id="Flutter Performance" order="8" side_tool="true" />
       <window_info anchor="bottom" id="Version Control" order="9" />
@@ -188,10 +211,24 @@
         </state>
       </provider>
     </entry>
+    <entry file="file://C:/flutter/flutter/packages/flutter/lib/src/services/platform_channel.dart">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="298">
+          <caret line="311" column="12" selection-start-line="311" selection-start-column="12" selection-end-line="311" selection-end-column="12" />
+        </state>
+      </provider>
+    </entry>
     <entry file="file://$PROJECT_DIR$/lib/speech_plugin.dart">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="187">
-          <caret line="45" column="19" selection-start-line="45" selection-start-column="7" selection-end-line="45" selection-end-column="19" />
+        <state relative-caret-position="352">
+          <caret line="18" column="19" lean-forward="true" selection-start-line="18" selection-start-column="19" selection-end-line="18" selection-end-column="19" />
+        </state>
+      </provider>
+    </entry>
+    <entry file="file://$PROJECT_DIR$/.gitignore">
+      <provider selected="true" editor-type-id="text-editor">
+        <state relative-caret-position="154">
+          <caret line="7" selection-start-line="7" selection-end-line="7" />
         </state>
       </provider>
     </entry>

BIN=BIN
android/.idea/caches/build_file_checksums.ser


+ 33 - 26
android/src/main/kotlin/cn/i2edu/speech_plugin/SpeechPlugin.kt

@@ -29,18 +29,20 @@ import java.io.RandomAccessFile
 import java.util.*
 
 class SpeechPlugin: MethodCallHandler {
-  
-  companion object {
-    private lateinit var context: Context
-    private lateinit var channel: MethodChannel
-    @JvmStatic
-    fun registerWith(registrar: Registrar) {
-      if (registrar.activity() == null) return
-      channel = MethodChannel(registrar.messenger(), "speech_plugin")
-      context = registrar.activeContext()
-      channel.setMethodCallHandler(SpeechPlugin())
+
+    companion object {
+        private lateinit var context: Context
+        private lateinit var channel: MethodChannel
+        private var evaluatorType: Int = 0
+
+        @JvmStatic
+        fun registerWith(registrar: Registrar) {
+            if (registrar.activity() == null) return
+            channel = MethodChannel(registrar.messenger(), "speech_plugin")
+            context = registrar.activeContext()
+            channel.setMethodCallHandler(SpeechPlugin())
+        }
     }
-  }
 
   override fun onMethodCall(call: MethodCall, result: Result) {
     if (call.method == "getPlatformVersion") {
@@ -49,21 +51,23 @@ class SpeechPlugin: MethodCallHandler {
       SpeechUtility.createUtility(context, SpeechConstant.APPID +"=5da1549c")
       result.success(true)
     } else if (call.method == "evaluatorByAudio") {
-      val pathEvaluatorDecode = call.argument<String>("pathEvaluatorDecode")!!
-      val index = call.argument<Int>("index")!!
-      val videoId = call.argument<String>("videoId")!!
-      val recordPath = call.argument<String>("recordPath")!!
-      val en = call.argument<String>("en")!!
+        val pathEvaluatorDecode = call.argument<String>("pathEvaluatorDecode")!!
+        val index = call.argument<Int>("index")!!
+        val videoId = call.argument<String>("videoId")!!
+        val recordPath = call.argument<String>("recordPath")!!
+        val en = call.argument<String>("en")!!
+        evaluatorType = call.argument<Int>("evaluatorType")!!
 
-      evaluatorRecord(pathEvaluatorDecode, index, recordPath, en, false)
+        evaluatorRecord(pathEvaluatorDecode, index, recordPath, en, false)
     } else if (call.method == "evaluatorByMp4") {
-      val pathEvaluatorDecode = call.argument<String>("pathEvaluatorDecode")!!
-      val index = call.argument<Int>("index")!!
-      val videoId = call.argument<String>("videoId")!!
-      val recordPath = call.argument<String>("recordPath")!!
-      val en = call.argument<String>("en")!!
+        val pathEvaluatorDecode = call.argument<String>("pathEvaluatorDecode")!!
+        val index = call.argument<Int>("index")!!
+        val videoId = call.argument<String>("videoId")!!
+        val recordPath = call.argument<String>("recordPath")!!
+        val en = call.argument<String>("en")!!
+        evaluatorType = call.argument<Int>("evaluatorType")!!
 
-      evaluatorVideoRecord(pathEvaluatorDecode, index, videoId, recordPath, en)
+        evaluatorVideoRecord(pathEvaluatorDecode, index, videoId, recordPath, en)
     } else {
       result.notImplemented()
     }
@@ -131,10 +135,13 @@ class SpeechPlugin: MethodCallHandler {
                       }
                     }
 
-                    channel.invokeMethod("evaluatorResult", mapOf("index" to index,"score" to (if(parseResult.is_rejected) null else parseResult.total_score), "words" to JSON.toJSONString(formatWords)))
+                    channel.invokeMethod("evaluatorResult",
+                            mapOf("index" to index,"score" to (if(parseResult.is_rejected) null else parseResult.total_score), "integrity_score" to (if(parseResult.is_rejected) null else parseResult.integrity_score),
+                                    "accuracy_score" to (if(parseResult.is_rejected) null else parseResult.accuracy_score), "fluency_score" to (if(parseResult.is_rejected) null else parseResult.fluency_score),
+                                    "words" to JSON.toJSONString(formatWords)))
                   } else {
 //                    Toast.makeText(context, "识别失败,结果为空", Toast.LENGTH_SHORT).show()
-                    channel.invokeMethod("evaluatorResult", mapOf("index" to index,"score" to null))
+                    channel.invokeMethod("evaluatorResult", mapOf("index" to index,"score" to null, "integrity_score" to null, "accuracy_score" to null, "fluency_score" to null))
                   }
                 }
               }
@@ -147,7 +154,7 @@ class SpeechPlugin: MethodCallHandler {
                 }
               }
             })
-            ?.startEvaluator(en, recordPath, decodePath)
+            ?.startEvaluator(en, recordPath, decodePath, evaluatorType)
   }
 
 }

+ 8 - 1
android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/FinalResult.java

@@ -11,7 +11,14 @@ public class FinalResult extends Result {
 	public int ret;
 	
 	public float total_score;
-	
+
+	public float accuracy_score;
+
+	public float fluency_score;
+
+	public float integrity_score;
+
+
 	@Override
 	public String toString() {
 		return "返回值:" + ret + ",总分:" + total_score;

+ 12 - 0
android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/Result.java

@@ -36,6 +36,18 @@ public class Result {
 	 * 总得分
 	 */
 	public float total_score;
+	/**
+	 * 准确度评分
+	 */
+	public float accuracy_score;
+	/**
+	 * 流畅度评分
+	 */
+	public float fluency_score;
+	/**
+	 * 完整度评分
+	 */
+	public float integrity_score;
 	/**
 	 * 时长(cn)
 	 */

+ 9 - 0
android/src/main/kotlin/cn/i2edu/speech_plugin/audioUtils/audioEvaluator/resultParse/XmlResultParser.java

@@ -49,6 +49,12 @@ public class XmlResultParser {
 						finalResult.ret = getInt(pullParser, "value");
 					} else if ("total_score".equals(pullParser.getName())) {
 						finalResult.total_score = getFloat(pullParser, "value");
+					} else if ("integrity_score".equals(pullParser.getName())) {
+						finalResult.integrity_score = getFloat(pullParser, "value");
+					} else if ("accuracy_score".equals(pullParser.getName())) {
+						finalResult.accuracy_score = getFloat(pullParser, "value");
+					} else if ("fluency_score".equals(pullParser.getName())) {
+						finalResult.fluency_score = getFloat(pullParser, "value");
 					} else if ("xml_result".equals(pullParser.getName())) {
 						// 详细结果
 						return parseResult(pullParser);
@@ -175,6 +181,9 @@ public class XmlResultParser {
 		result.end_pos = getInt(pullParser, "end_pos");
 		result.content = getContent(pullParser);
 		result.total_score = getFloat(pullParser, "total_score");
+		result.integrity_score = getFloat(pullParser, "integrity_score");
+		result.accuracy_score = getFloat(pullParser, "accuracy_score");
+		result.fluency_score = getFloat(pullParser, "fluency_score");
 		result.time_len = getInt(pullParser, "time_len");
 		result.except_info = getExceptInfo(pullParser);
 		result.is_rejected = getIsRejected(pullParser);

+ 4 - 1
android/src/main/kotlin/cn/i2edu/speech_plugin/util/AudioEvaluatorUtil.kt

@@ -33,10 +33,13 @@ class AudioEvaluatorUtil private constructor(val context: Context){
         }
     }
 
-    fun startEvaluator(en: String, filePath: String, decodedFilePath: String) {
+    fun startEvaluator(en: String, filePath: String, decodedFilePath: String, evaluatorType: Int) {
         speechEvaluator?.setParameter(SpeechConstant.LANGUAGE, "en_us")
         speechEvaluator?.setParameter(SpeechConstant.ISE_CATEGORY, "read_sentence")
         speechEvaluator?.setParameter(SpeechConstant.AUDIO_SOURCE,"-1")
+        if (evaluatorType == 1) {
+            speechEvaluator?.setParameter("plev", "0")
+        }
 
         if (!File(decodedFilePath).exists()) {
             File(decodedFilePath).createNewFile()

+ 9 - 2
lib/speech_plugin.dart

@@ -10,6 +10,7 @@ class SpeechPlugin {
 
   StreamController _onEvaluatorChange;
   Stream<Map> get evaluator => _onEvaluatorChange.stream;
+  static int evaluatorType = 0;
 
   static SpeechPlugin get instance => _instance;
 
@@ -22,13 +23,18 @@ class SpeechPlugin {
     return _channel.invokeMethod("initSpeechSdk");
   }
 
+  void updateEvaluatorType(int type) {
+    SpeechPlugin.evaluatorType = type; // 1为开启全维度,0为关闭
+  }
+
  Future<Map> evaluatorByAudio(String pathEvaluatorDecode, int index, String videoId, String recordPath, String en) {
     return _channel.invokeMethod("evaluatorByAudio", {
       "pathEvaluatorDecode": pathEvaluatorDecode,
       "index": index,
       "videoId": videoId,
       "recordPath": recordPath,
-      "en": en
+      "en": en,
+      "evaluatorType": evaluatorType,
     });
  }
 
@@ -38,7 +44,8 @@ class SpeechPlugin {
      "index": index,
      "videoId": videoId,
      "recordPath": recordPath,
-     "en": en
+     "en": en,
+     "evaluatorType": evaluatorType,
    });
  }
 

+ 0 - 1
speech_plugin.iml

@@ -11,7 +11,6 @@
       <excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
       <excludeFolder url="file://$MODULE_DIR$/example/.pub" />
       <excludeFolder url="file://$MODULE_DIR$/example/build" />
-      <excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/App.framework/flutter_assets/packages" />
     </content>
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="Dart SDK" level="project" />