Browse Source

vosk离线语音识别功能集成,效果不太行

weizhengliang 1 year ago
parent
commit
ca48ef29cf
38 changed files with 1462 additions and 339 deletions
  1. 3 1
      android_host/build.gradle
  2. 63 0
      android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt
  3. 336 333
      android_host/src/main/h10_wke_1h/res/layout/activity_nurse_home.xml
  4. 2 0
      build.gradle
  5. 1 0
      middleware/build.gradle
  6. 5 4
      middleware/src/main/code/com/wdkl/ncs/android/middleware/helper/SoundPoolManager.java
  7. BIN
      resource/src/main/res/raw/tips.mp3
  8. 3 1
      settings.gradle
  9. 1 0
      vosk/.gitignore
  10. 51 0
      vosk/build.gradle
  11. BIN
      vosk/libs/vosk-android-0.3.47.aar
  12. 6 0
      vosk/src/main/AndroidManifest.xml
  13. 23 0
      vosk/src/main/java/com/vosk/VoiceRecognizer.java
  14. 56 0
      vosk/src/main/java/com/vosk/VoiceRecognizerManager.java
  15. 13 0
      vosk/src/main/java/com/vosk/VoskRecognitionListener.java
  16. 168 0
      vosk/src/main/java/com/vosk/VoskVoiceRecognizer.java
  17. BIN
      vosk/src/main/models/assets/model-en-us/am.png
  18. BIN
      vosk/src/main/models/assets/model-en-us/conf.png
  19. 7 0
      vosk/src/main/models/assets/model-en-us/conf/mfcc.conf
  20. 10 0
      vosk/src/main/models/assets/model-en-us/conf/model.conf
  21. BIN
      vosk/src/main/models/assets/model-en-us/files_need.png
  22. BIN
      vosk/src/main/models/assets/model-en-us/graph.png
  23. BIN
      vosk/src/main/models/assets/model-en-us/ivector.png
  24. 0 0
      vosk/src/main/models/assets/model-en-us/log.txt
  25. 6 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/README
  26. BIN
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/am/final.mdl
  27. 8 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/conf/mfcc.conf
  28. 10 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/conf/model.conf
  29. BIN
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/Gr.fst
  30. BIN
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/HCLr.fst
  31. 39 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/disambig_tid.int
  32. 646 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/phones/word_boundary.int
  33. BIN
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/final.dubm
  34. BIN
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/final.ie
  35. BIN
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/final.mat
  36. 3 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/global_cmvn.stats
  37. 0 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/online_cmvn.conf
  38. 2 0
      vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/splice.conf

+ 3 - 1
android_host/build.gradle

@@ -96,7 +96,7 @@ dependencies {
      */
     compile project(':middleware')
 
-    if(componentTag){
+    if (componentTag) {
         debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
         releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
         testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
@@ -139,6 +139,8 @@ dependencies {
 
     //广播喊话组件
     compile project(':gstream')
+
+    compile project(':vosk')
 }
 
 /**

+ 63 - 0
android_host/src/main/h10_wke_1h/java/com/wdkl/ncs/android/component/nursehome/activity/NurseHomeActivity.kt

@@ -29,6 +29,8 @@ import com.enation.javashop.net.engine.plugin.permission.RxPermissions
 import com.google.common.base.Strings
 import com.google.gson.Gson
 import com.serenegiant.helper.ScreenRecordHelper
+import com.vosk.VoiceRecognizerManager
+import com.vosk.VoskRecognitionListener
 import com.wdkl.ncs.android.component.nursehome.R
 import com.wdkl.ncs.android.middleware.common.Constants
 import com.wdkl.ncs.android.component.nursehome.databinding.ActivityNurseHomeBinding
@@ -106,6 +108,7 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
 
     private val QR_CODE_PATH = "http://m.wdklian.com/care/apk/care.user?type=NCS_DEVICE"
     private val handler by lazy { Handler(Looper.getMainLooper()) }
+    private val voiceHandler by lazy { Handler(Looper.myLooper()!!) }
     private var executor: ScheduledExecutorService? = null
     private var serverIp = ""
     private var serverSuccess = false
@@ -712,6 +715,60 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
         updatePower()
 
         language = LocaleMangerUtils.getApplicationLocale().language
+
+        if (BuildConfig.voice_recognizer.toBoolean()) {
+            //语音识别
+            VoiceRecognizerManager.getInstance().initModel(BaseApplication.appContext)
+            VoiceRecognizerManager.getInstance().setVoskRecogListener(object : VoskRecognitionListener {
+                override fun onPartResult(value: String?) {
+                    //
+                }
+
+                override fun onResult(value: String?) {
+                    val result = value?.replace("\\s".toRegex(), "")
+                    Log.e(TAG, "voice text: $result")
+                    if (result!!.contains("小维") || result.contains("小薇") || result.contains("小微") || result.contains("小为")) {
+                        if (result.contains("接听") || result.contains("接通")) {
+                            SoundPoolManager.getInstance().playSound(8, 1.0f, 1.0f, 0)
+                            if (callingList.size > 0) {
+                                if (Constants.CALL_STATE == Constants.CALL_STANDBY) {
+                                    //不是呼出也不是通话状态则接听电话
+                                    SpeechUtil.getInstance().speakSingleText("好的")
+                                    EventBus.getDefault().post(MessageEvent("hookoff", Constants.EVENT_HOOK_OFF))
+                                    VoiceRecognizerManager.getInstance().setPause(true)
+                                }
+                            } else if (Constants.CALL_STATE == Constants.CALL_VISITING || Constants.CALL_STATE == Constants.CALL_V_INCOMING) {
+                                SpeechUtil.getInstance().speakSingleText("好的")
+                                EventBus.getDefault().post(MessageEvent("hookoff", Constants.EVENT_V_HOOK_OFF))
+                                VoiceRecognizerManager.getInstance().setPause(true)
+                            } else {
+                                SpeechUtil.getInstance().speakSingleText("当前没有呼叫")
+                            }
+                        }
+                    }
+                }
+
+                override fun onFinalResult(value: String?) {
+                    //
+                }
+
+                override fun onTimeout() {
+                    //
+                }
+
+                override fun onError(ex: java.lang.Exception?) {
+                    //
+                }
+            })
+
+            //启动语音识别
+            //VoiceRecognizerManager.getInstance().recognizeMicrophone()
+            //SpeechUtil.getInstance().speakSingleText("语音助手正在开启,请稍后")
+            voiceHandler.postDelayed({
+                VoiceRecognizerManager.getInstance().recognizeMicrophone()
+                //SoundPoolManager.getInstance()
+            }, 15000)
+        }
     }
 
     private fun getPower(): Int {
@@ -1090,6 +1147,7 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
      */
     override fun destory() {
         handler.removeCallbacksAndMessages(null)
+        voiceHandler.removeCallbacksAndMessages(null)
         Constants.CALL_STATE = Constants.CALL_STANDBY
         if (receiver != null) {
             unregisterReceiver(receiver)
@@ -1112,6 +1170,10 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
             executor!!.shutdownNow()
         }
         SoundPoolManager.getInstance().release()
+
+        if (BuildConfig.voice_recognizer.toBoolean()) {
+            VoiceRecognizerManager.getInstance().release()
+        }
     }
 
     /**
@@ -2093,6 +2155,7 @@ class NurseHomeActivity  : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
 
             //退出通话界面
             Constants.EVENT_REMOVE_CALL_FRAGMENT -> {
+                VoiceRecognizerManager.getInstance().setPause(false)
                 if (skyCallFragment != null) {
                     removeCallFragment()
                 }

+ 336 - 333
android_host/src/main/h10_wke_1h/res/layout/activity_nurse_home.xml

@@ -1,359 +1,360 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@color/javashop_color_white">
+
+        <RelativeLayout
+            android:id="@+id/title_relayout"
             android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:background="@color/javashop_color_white">
+            android:layout_height="48dp">
 
-            <RelativeLayout
-                android:id="@+id/title_relayout"
-                android:layout_width="match_parent"
-                android:layout_height="48dp">
-
-                <!--SIP状态图标-->
-                <TextView
-                    android:id="@+id/view_title_layout_tv_point"
-                    android:layout_width="24dp"
-                    android:layout_height="24dp"
-                    android:layout_centerVertical="true"
-                    android:gravity="center"
-                    android:layout_marginLeft="10dp"
-                    android:textColor="@color/text_room_color"
-                    android:background="@color/red_color"/>
+            <!--SIP状态图标-->
+            <TextView
+                android:id="@+id/view_title_layout_tv_point"
+                android:layout_width="24dp"
+                android:layout_height="24dp"
+                android:layout_centerVertical="true"
+                android:layout_marginLeft="10dp"
+                android:background="@color/red_color"
+                android:gravity="center"
+                android:textColor="@color/text_room_color" />
 
-                <TextView
-                    android:id="@+id/name_of_organization_tv"
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
-                    android:layout_marginLeft="10dp"
-                    android:layout_toRightOf="@id/view_title_layout_tv_point"
-                    android:gravity="center"
-                    android:text="----"
-                    android:textColor="#2F9DF1"
-                    android:textSize="22sp" />
+            <TextView
+                android:id="@+id/name_of_organization_tv"
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_marginLeft="10dp"
+                android:layout_toRightOf="@id/view_title_layout_tv_point"
+                android:gravity="center"
+                android:text="----"
+                android:textColor="#2F9DF1"
+                android:textSize="22sp" />
+
+            <TextClock
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_centerHorizontal="true"
+                android:layout_centerVertical="true"
+                android:format12Hour="yyyy-MM-dd HH:mm EEEE"
+                android:format24Hour="yyyy-MM-dd HH:mm EEEE"
+                android:textColor="#2F9DF1"
+                android:textSize="22sp" />
 
-                <TextClock
+            <RelativeLayout
+                android:layout_width="wrap_content"
+                android:layout_height="match_parent"
+                android:layout_alignParentRight="true"
+                android:gravity="center">
+
+                <LinearLayout
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_centerHorizontal="true"
-                    android:layout_centerVertical="true"
-                    android:format12Hour="yyyy-MM-dd HH:mm EEEE"
-                    android:format24Hour="yyyy-MM-dd HH:mm EEEE"
-                    android:textColor="#2F9DF1"
-                    android:textSize="22sp" />
-
-                <RelativeLayout
-                    android:layout_width="wrap_content"
-                    android:layout_height="match_parent"
-                    android:layout_alignParentRight="true"
-                    android:gravity="center">
+                    android:gravity="center_vertical"
+                    android:orientation="horizontal">
 
-                    <LinearLayout
+                    <com.wdkl.ncs.android.lib.widget.MarqueeTextView
+                        android:id="@+id/tv_broadcast_state"
+                        android:layout_width="100dp"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="8dp"
+                        android:drawableLeft="@drawable/ic_broadcast"
+                        android:drawablePadding="4dp"
+                        android:ellipsize="marquee"
+                        android:focusable="true"
+                        android:focusableInTouchMode="true"
+                        android:marqueeRepeatLimit="-1"
+                        android:singleLine="true"
+                        android:text="@string/broadcast_playing"
+                        android:textColor="@color/red_color"
+                        android:textSize="20sp"
+                        android:visibility="gone" />
+
+                    <TextView
+                        android:id="@+id/tv_device_id"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:orientation="horizontal"
-                        android:gravity="center_vertical">
-
-                        <com.wdkl.ncs.android.lib.widget.MarqueeTextView
-                            android:id="@+id/tv_broadcast_state"
-                            android:layout_width="100dp"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="8dp"
-                            android:drawableLeft="@drawable/ic_broadcast"
-                            android:drawablePadding="4dp"
-                            android:ellipsize="marquee"
-                            android:focusable="true"
-                            android:focusableInTouchMode="true"
-                            android:marqueeRepeatLimit="-1"
-                            android:singleLine="true"
-                            android:text="@string/broadcast_playing"
-                            android:textColor="@color/red_color"
-                            android:textSize="20sp"
-                            android:visibility="gone"/>
-
-                        <TextView
-                            android:id="@+id/tv_device_id"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="16dp"
-                            android:text="ID: --"
-                            android:textColor="#2F9DF1"
-                            android:textSize="20sp"/>
-
-                        <ImageView
-                            android:id="@+id/battery_state_img"
-                            android:layout_width="28dp"
-                            android:layout_height="28dp"
-                            android:layout_gravity="center_vertical"
-                            android:layout_marginRight="10dp"
-                            android:src="@drawable/wdkl_stat_sys_battery"/>
-
-                        <!--   蓝牙状态  -->
-                        <ImageView
-                            android:id="@+id/bluetooth_state_imagev"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="16dp"
-                            android:visibility="gone"/>
-                        <!--   WiFi状态  -->
-                        <ImageView
-                            android:id="@+id/wifi_state_imagev"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="16dp" />
-
-                        <!-- 以太网 -->
-                        <ImageView
-                            android:id="@+id/ethernet_state_imagev"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="16dp" />
-
-                        <!--   tcp连接状态  -->
-                        <ImageView
-                            android:id="@+id/tcp_state_imagev"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="16dp"
-                            android:src="@drawable/ic_tcp_fail"/>
-
-                        <!--白昼状态-->
-                        <ImageView
-                            android:id="@+id/day_night_state_imagev"
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="16dp" />
-
-                    </LinearLayout>
-                </RelativeLayout>
-            </RelativeLayout>
+                        android:layout_marginRight="16dp"
+                        android:text="ID: --"
+                        android:textColor="#2F9DF1"
+                        android:textSize="20sp" />
+
+                    <ImageView
+                        android:id="@+id/battery_state_img"
+                        android:layout_width="28dp"
+                        android:layout_height="28dp"
+                        android:layout_gravity="center_vertical"
+                        android:layout_marginRight="10dp"
+                        android:src="@drawable/wdkl_stat_sys_battery" />
+
+                    <!--   蓝牙状态  -->
+                    <ImageView
+                        android:id="@+id/bluetooth_state_imagev"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="16dp"
+                        android:visibility="gone" />
+                    <!--   WiFi状态  -->
+                    <ImageView
+                        android:id="@+id/wifi_state_imagev"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="16dp" />
 
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:layout_above="@+id/bottom_linlyout"
-                android:layout_below="@+id/title_relayout">
+                    <!-- 以太网 -->
+                    <ImageView
+                        android:id="@+id/ethernet_state_imagev"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="16dp" />
 
-                <FrameLayout
-                    android:id="@+id/left_framlyout"
-                    android:layout_width="0dp"
-                    android:layout_height="match_parent"
-                    android:layout_weight="0.8"/>
+                    <!--   tcp连接状态  -->
+                    <ImageView
+                        android:id="@+id/tcp_state_imagev"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="16dp"
+                        android:src="@drawable/ic_tcp_fail" />
 
+                    <!--白昼状态-->
+                    <ImageView
+                        android:id="@+id/day_night_state_imagev"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginRight="16dp" />
+
+                </LinearLayout>
+            </RelativeLayout>
+        </RelativeLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_above="@+id/bottom_linlyout"
+            android:layout_below="@+id/title_relayout">
+
+            <FrameLayout
+                android:id="@+id/left_framlyout"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="0.8" />
 
-                <FrameLayout
-                    android:id="@+id/middle_fralyout"
-                    android:layout_width="0dp"
-                    android:layout_height="match_parent"
-                    android:layout_toRightOf="@+id/left_framlyout"
-                    android:layout_weight="1.6"/>
 
-            </LinearLayout>
             <FrameLayout
-                android:id="@+id/right_fralyout"
-                android:layout_width="480dp"
+                android:id="@+id/middle_fralyout"
+                android:layout_width="0dp"
                 android:layout_height="match_parent"
-                android:layout_above="@+id/bottom_linlyout"
-                android:layout_below="@+id/title_relayout"
-                android:layout_alignParentRight="true"/>
+                android:layout_toRightOf="@+id/left_framlyout"
+                android:layout_weight="1.6" />
+
+        </LinearLayout>
+
+        <FrameLayout
+            android:id="@+id/right_fralyout"
+            android:layout_width="480dp"
+            android:layout_height="match_parent"
+            android:layout_above="@+id/bottom_linlyout"
+            android:layout_below="@+id/title_relayout"
+            android:layout_alignParentRight="true" />
+
+        <LinearLayout
+            android:id="@+id/bottom_linlyout"
+            android:layout_width="match_parent"
+            android:layout_height="60dp"
+            android:layout_alignParentBottom="true"
+            android:background="#2F9DF1"
+            android:orientation="horizontal">
 
             <LinearLayout
-                android:id="@+id/bottom_linlyout"
                 android:layout_width="match_parent"
-                android:layout_height="60dp"
-                android:layout_alignParentBottom="true"
-                android:background="#2F9DF1"
+                android:layout_height="match_parent"
                 android:orientation="horizontal">
 
-                <LinearLayout
+                <RadioGroup
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
                     android:orientation="horizontal">
 
-                    <RadioGroup
-                        android:layout_width="match_parent"
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/home_radio_bt"
+                        android:layout_width="wrap_content"
                         android:layout_height="match_parent"
-                        android:orientation="horizontal">
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/home_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/shou_ye_no"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_home"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/broadcast_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/guang_bo"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_broadcast"
-                            android:textSize="24sp"
-                            android:visibility="gone"/>
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/visit_an_extension_radio_bt"
-                            android:layout_width="0dp"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_broadcast_icon"
-                            android:gravity="center"
-                            android:textColor="#FFFFFF"
-                            android:text="@string/str_visiting"
-                            android:textSize="16sp"
-                            android:visibility="gone" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/doctor_host_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/ic_doctor"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_doctor"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/inpatient_ward_radio_bt"
-                            android:layout_width="0dp"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_inpatient_ward_icon"
-                            android:gravity="center"
-                            android:textColor="#FFFFFF"
-                            android:text="@string/str_ward"
-                            android:textSize="16sp"
-                            android:visibility="gone" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/sickbed_radio_bt"
-                            android:layout_width="0dp"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_broadcast_icon"
-                            android:gravity="center"
-                            android:textColor="#FFFFFF"
-                            android:text="@string/str_sick_bed"
-                            android:textSize="16sp"
-                            android:visibility="gone" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/nurse_move_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_move_icon"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_mobile"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/other_host_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_other_host_icon"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_other_host"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/collocation_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_other_host_icon"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_trusteeship"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/led_settings_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_set_icon"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_led"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.BadgeRadioButton
-                            android:id="@+id/nb_device_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/ic_nb_iot_device"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_nb_iot"
-                            android:textSize="24sp" />
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/note_message_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/ic_message"
-                            android:drawablePadding="10dp"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_note_message"
-                            android:textSize="24sp"
-                            android:visibility="gone"/>
-
-                        <com.wdkl.ncs.android.lib.widget.CustomRadioButton
-                            android:id="@+id/system_settings_radio_bt"
-                            android:layout_width="wrap_content"
-                            android:layout_height="match_parent"
-                            android:layout_weight="1"
-                            android:button="@null"
-                            android:drawableLeft="@drawable/selt_set_icon"
-                            android:drawablePadding="10px"
-                            android:gravity="center"
-                            android:textColor="@drawable/selector_bottom_btn_text_color"
-                            android:text="@string/str_settings"
-                            android:textSize="24sp" />
-
-                        <TextView
-                            android:layout_width="0dp"
-                            android:layout_height="wrap_content"
-                            android:layout_weight="5"/>
-
-                    </RadioGroup>
-                </LinearLayout>
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/shou_ye_no"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_home"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/broadcast_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/guang_bo"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_broadcast"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp"
+                        android:visibility="gone" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/visit_an_extension_radio_bt"
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_broadcast_icon"
+                        android:gravity="center"
+                        android:text="@string/str_visiting"
+                        android:textColor="#FFFFFF"
+                        android:textSize="16sp"
+                        android:visibility="gone" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/doctor_host_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/ic_doctor"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_doctor"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/inpatient_ward_radio_bt"
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_inpatient_ward_icon"
+                        android:gravity="center"
+                        android:text="@string/str_ward"
+                        android:textColor="#FFFFFF"
+                        android:textSize="16sp"
+                        android:visibility="gone" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/sickbed_radio_bt"
+                        android:layout_width="0dp"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_broadcast_icon"
+                        android:gravity="center"
+                        android:text="@string/str_sick_bed"
+                        android:textColor="#FFFFFF"
+                        android:textSize="16sp"
+                        android:visibility="gone" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/nurse_move_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_move_icon"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_mobile"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/other_host_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_other_host_icon"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_other_host"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/collocation_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_other_host_icon"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_trusteeship"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/led_settings_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_set_icon"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_led"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.BadgeRadioButton
+                        android:id="@+id/nb_device_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/ic_nb_iot_device"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_nb_iot"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/note_message_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/ic_message"
+                        android:drawablePadding="10dp"
+                        android:gravity="center"
+                        android:text="@string/str_note_message"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp"
+                        android:visibility="gone" />
+
+                    <com.wdkl.ncs.android.lib.widget.CustomRadioButton
+                        android:id="@+id/system_settings_radio_bt"
+                        android:layout_width="wrap_content"
+                        android:layout_height="match_parent"
+                        android:layout_weight="1"
+                        android:button="@null"
+                        android:drawableLeft="@drawable/selt_set_icon"
+                        android:drawablePadding="10px"
+                        android:gravity="center"
+                        android:text="@string/str_settings"
+                        android:textColor="@drawable/selector_bottom_btn_text_color"
+                        android:textSize="24sp" />
+
+                    <TextView
+                        android:layout_width="0dp"
+                        android:layout_height="wrap_content"
+                        android:layout_weight="5" />
+
+                </RadioGroup>
             </LinearLayout>
+        </LinearLayout>
 
         <!--通话界面-->
         <FrameLayout
@@ -367,15 +368,15 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:background="@color/white"
-            android:orientation="vertical"
-            android:gravity="center_horizontal">
+            android:gravity="center_horizontal"
+            android:orientation="vertical">
 
             <ImageView
                 android:id="@+id/home_view_qr_code"
-                android:layout_marginTop="10dp"
                 android:layout_width="280dp"
                 android:layout_height="280dp"
-                android:layout_gravity="center_horizontal" />
+                android:layout_gravity="center_horizontal"
+                android:layout_marginTop="10dp" />
 
             <TextView
                 android:id="@+id/home_view_device_model"
@@ -385,7 +386,7 @@
                 android:text="rom:"
                 android:textColor="@color/black"
                 android:textSize="20sp"
-                android:visibility="gone"/>
+                android:visibility="gone" />
 
             <TextView
                 android:id="@+id/home_view_local_ip"
@@ -427,7 +428,7 @@
                 android:text="MCU:"
                 android:textColor="@color/black"
                 android:textSize="20sp"
-                android:visibility="gone"/>
+                android:visibility="gone" />
 
             <TextView
                 android:id="@+id/home_view_device_state"
@@ -442,6 +443,7 @@
                 android:layout_height="wrap_content"
                 android:layout_marginTop="20dp"
                 android:gravity="center">
+
                 <Button
                     android:id="@+id/btn_get_server"
                     android:layout_width="140dp"
@@ -449,7 +451,7 @@
                     android:background="#2F9DF1"
                     android:text="@string/register_auto_config"
                     android:textSize="20sp"
-                    android:visibility="gone"/>
+                    android:visibility="gone" />
 
                 <Button
                     android:id="@+id/btn_set_debug"
@@ -495,6 +497,7 @@
                     android:background="#2F9DF1"
                     android:text="@string/register_reboot"
                     android:textSize="20sp" />
+
                 <Button
                     android:id="@+id/btn_test"
                     android:layout_width="140dp"

+ 2 - 0
build.gradle

@@ -55,6 +55,7 @@ buildscript {
 
     //OEM: wdkl,legrand
     ext.oem_name = "wdkl"
+    ext.voice_recognizer = false
 
     if (app_device_type == "zj_h10_z_3128_1") {
         //rk3128 10寸护士主机
@@ -162,6 +163,7 @@ allprojects {
 
         flatDir {
             dirs '../common/libs' //申明本地库
+            dirs '../vosk/libs'
         }
     }
 }

+ 1 - 0
middleware/build.gradle

@@ -29,6 +29,7 @@ android {
         buildConfigField "String", "BUILD_TIME", getDate()
         buildConfigField "String", "APP_DEVICE_TYPE", "\""+app_device_type+"\""
         buildConfigField 'String', 'OEM_NAME', "\"${project.rootProject.ext.oem_name}\""
+        buildConfigField 'String', 'voice_recognizer', "\"${project.rootProject.ext.voice_recognizer}\""
     }
 
     lintOptions {

+ 5 - 4
middleware/src/main/code/com/wdkl/ncs/android/middleware/helper/SoundPoolManager.java

@@ -30,10 +30,10 @@ public class SoundPoolManager {
             return;
         }
 
-        if(Build.VERSION.SDK_INT > 21){
+        if (Build.VERSION.SDK_INT > 21) {
             SoundPool.Builder builder = new SoundPool.Builder();
             //传入音频数量
-            builder.setMaxStreams(5);
+            builder.setMaxStreams(8);
             //AudioAttributes是一个封装音频各种属性的方法
             AudioAttributes.Builder attrBuilder = new AudioAttributes.Builder();
             //设置音频流的合适的属性
@@ -41,8 +41,8 @@ public class SoundPoolManager {
             //加载一个AudioAttributes
             builder.setAudioAttributes(attrBuilder.build());
             soundPool = builder.build();
-        }else{
-            soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
+        } else {
+            soundPool = new SoundPool(8, AudioManager.STREAM_MUSIC, 0);
         }
 
         //来电
@@ -55,6 +55,7 @@ public class SoundPoolManager {
         soundID.put(5, soundPool.load(BaseApplication.appContext, R.raw.err, 1));
         soundID.put(6, soundPool.load(BaseApplication.appContext, R.raw.test_start2,  1));
         soundID.put(7, soundPool.load(BaseApplication.appContext, R.raw.test_start3,  1));
+        soundID.put(8, soundPool.load(BaseApplication.appContext, R.raw.tips,  1));
         soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
             @Override
             public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {

BIN
resource/src/main/res/raw/tips.mp3


+ 3 - 1
settings.gradle

@@ -1,3 +1,5 @@
-include ':app', ':common', ':resource', ':middleware', ':android_host', ':nurseMainLib', ':listenvision', ':janus', ':gstream'
+include ':app', ':common', ':resource', ':middleware',
+        ':android_host', ':nurseMainLib', ':listenvision',
+        ':janus', ':gstream', ':vosk'
 
 //'webrtc', 'rtc-chat', 'libwebrtc',

+ 1 - 0
vosk/.gitignore

@@ -0,0 +1 @@
+/build

+ 51 - 0
vosk/build.gradle

@@ -0,0 +1,51 @@
+apply plugin: 'com.android.library'
+
+android {
+    compileSdkVersion target_sdk_version
+    buildToolsVersion build_tools_version
+
+    defaultConfig {
+        minSdkVersion min_sdk_version
+        targetSdkVersion target_sdk_version
+        versionCode app_version_code
+        versionName app_version
+        ndk {
+            //abiFilters 'armeabi-v7a', 'arm64-v8a'
+            abiFilters 'armeabi-v7a'
+        }
+    }
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+
+    sourceSets {
+        if (project.rootProject.ext.voice_recognizer.toBoolean()) {
+            main {
+                assets.srcDirs += "src/main/models/assets"
+                assets.srcDirs += "$buildDir/generated/assets"
+            }
+        }
+    }
+}
+
+dependencies {
+    implementation 'net.java.dev.jna:jna:5.8.0@aar'
+
+    compile project(':common')
+
+    api(name: 'vosk-android-0.3.47', ext: 'aar')
+}
+
+tasks.register('genUUID') {
+    def uuid = UUID.randomUUID().toString()
+    def odir = file("$buildDir/generated/assets/vosk-model-small-cn-0.22")
+    def ofile = file("$odir/uuid")
+    doLast {
+        mkdir odir
+        ofile.text = uuid
+    }
+}
+
+preBuild.dependsOn(genUUID)

BIN
vosk/libs/vosk-android-0.3.47.aar


+ 6 - 0
vosk/src/main/AndroidManifest.xml

@@ -0,0 +1,6 @@
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.vosk">
+
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <uses-permission android:name="android.permission.RECORD_AUDIO" />
+</manifest>

+ 23 - 0
vosk/src/main/java/com/vosk/VoiceRecognizer.java

@@ -0,0 +1,23 @@
+package com.vosk;
+
+import android.content.Context;
+
+public abstract class VoiceRecognizer {
+    protected VoskRecognitionListener voskRecognitionListener;
+
+    public abstract void initModel(Context context);
+
+    //音频文件识别
+    public abstract void recognizeFile(Context context);
+
+    //麦克风输入识别
+    public abstract void recognizeMicrophone();
+
+    public void setVoskRecognitionListener(VoskRecognitionListener listener) {
+        voskRecognitionListener = listener;
+    }
+
+    public abstract void setPause(boolean paused);
+
+    public abstract void release();
+}

+ 56 - 0
vosk/src/main/java/com/vosk/VoiceRecognizerManager.java

@@ -0,0 +1,56 @@
+package com.vosk;
+
+import android.content.Context;
+
+public class VoiceRecognizerManager {
+    private final static String TAG = VoiceRecognizerManager.class.getSimpleName();
+
+    private static VoiceRecognizerManager instance = null;
+    private VoiceRecognizer voiceRecognizer;
+
+    public static VoiceRecognizerManager getInstance(){
+        if (instance == null){
+            synchronized (VoiceRecognizerManager.class){
+                if (instance == null){
+                    instance = new VoiceRecognizerManager();
+                }
+            }
+        }
+        return instance;
+    }
+
+    public void initModel(Context context) {
+        voiceRecognizer = new VoskVoiceRecognizer();
+        voiceRecognizer.initModel(context);
+    }
+
+    public void recognizeFile(Context context) {
+        if (voiceRecognizer != null) {
+            voiceRecognizer.recognizeFile(context);
+        }
+    }
+
+    public void recognizeMicrophone() {
+        if (voiceRecognizer != null) {
+            voiceRecognizer.recognizeMicrophone();
+        }
+    }
+
+    public void setVoskRecogListener(VoskRecognitionListener listener) {
+        if (voiceRecognizer != null) {
+            voiceRecognizer.setVoskRecognitionListener(listener);
+        }
+    }
+
+    public void setPause(boolean pause) {
+        if (voiceRecognizer != null) {
+            voiceRecognizer.setPause(pause);
+        }
+    }
+
+    public void release() {
+        if (voiceRecognizer != null) {
+            voiceRecognizer.release();
+        }
+    }
+}

+ 13 - 0
vosk/src/main/java/com/vosk/VoskRecognitionListener.java

@@ -0,0 +1,13 @@
+package com.vosk;
+
+public interface VoskRecognitionListener {
+    void onPartResult(String value);
+
+    void onResult(String value);
+
+    void onFinalResult(String value);
+
+    void onError(Exception ex);
+
+    void onTimeout();
+}

+ 168 - 0
vosk/src/main/java/com/vosk/VoskVoiceRecognizer.java

@@ -0,0 +1,168 @@
+package com.vosk;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.alibaba.fastjson.JSONObject;
+
+import org.vosk.LibVosk;
+import org.vosk.LogLevel;
+import org.vosk.Model;
+import org.vosk.Recognizer;
+import org.vosk.android.RecognitionListener;
+import org.vosk.android.SpeechService;
+import org.vosk.android.SpeechStreamService;
+import org.vosk.android.StorageService;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class VoskVoiceRecognizer extends VoiceRecognizer {
+    private final static String TAG = VoskVoiceRecognizer.class.getSimpleName();
+
+    private Model model;
+    private SpeechService speechService;
+    private SpeechStreamService speechStreamService;
+    private RecognitionListener recognitionListener;
+
+    @Override
+    public void initModel(Context context) {
+        LibVosk.setLogLevel(LogLevel.INFO);
+
+        StorageService.unpack(context, "vosk-model-small-cn-0.22", "model",
+                (model) -> {
+                    this.model = model;
+                },
+                (exception) -> {
+                    Log.e(TAG, "Failed to unpack the model" + exception.getMessage());
+                });
+
+        recognitionListener = new RecognitionListener() {
+            @Override
+            public void onPartialResult(String s) {
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if (jsonObject != null) {
+                    String text = (String) jsonObject.get("text");
+                    if (!TextUtils.isEmpty(text)) {
+                        Log.e(TAG, "voice part: " + text);
+
+                        if (voskRecognitionListener != null) {
+                            voskRecognitionListener.onPartResult(text);
+                        }
+                    }
+                }
+            }
+
+            @Override
+            public void onResult(String s) {
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if (jsonObject != null) {
+                    String text = (String) jsonObject.get("text");
+                    Log.e(TAG, "voice result: " + text);
+
+                    if (voskRecognitionListener != null && !TextUtils.isEmpty(text)) {
+                        voskRecognitionListener.onResult(text);
+                    }
+                }
+            }
+
+            @Override
+            public void onFinalResult(String s) {
+                JSONObject jsonObject = JSONObject.parseObject(s);
+                if (jsonObject != null) {
+                    String text = (String) jsonObject.get("text");
+                    Log.e(TAG, "voice final: " + text);
+
+                    if (voskRecognitionListener != null) {
+                        voskRecognitionListener.onFinalResult(s);
+                    }
+                }
+
+                if (speechStreamService != null) {
+                    speechStreamService = null;
+                }
+            }
+
+            @Override
+            public void onError(Exception e) {
+                if (voskRecognitionListener != null) {
+                    voskRecognitionListener.onError(e);
+                }
+            }
+
+            @Override
+            public void onTimeout() {
+                if (voskRecognitionListener != null) {
+                    voskRecognitionListener.onTimeout();
+                }
+            }
+        };
+
+        Log.i(TAG, "voice recognizer initialized");
+    }
+
+    @Override
+    public void recognizeFile(Context context) {
+        if (speechStreamService != null) {
+            speechStreamService.stop();
+            speechStreamService = null;
+        } else {
+            try {
+                Recognizer rec = new Recognizer(model, 16000.f, "[\"one zero zero zero one\", " +
+                        "\"oh zero one two three four five six seven eight nine\", \"[unk]\"]");
+
+                InputStream ais = context.getAssets().open(
+                        "10001-90210-01803.wav");
+                if (ais.skip(44) != 44) throw new IOException("File too short");
+
+                speechStreamService = new SpeechStreamService(rec, ais, 16000);
+                speechStreamService.start(recognitionListener);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void recognizeMicrophone() {
+        if (speechService != null) {
+            speechService.stop();
+            speechService = null;
+        } else {
+            try {
+                Recognizer rec = new Recognizer(model, 16000.0f);
+                speechService = new SpeechService(rec, 16000.0f);
+                speechService.startListening(recognitionListener);
+
+                Log.i(TAG, "voice recognize microphone.");
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void setVoskRecognitionListener(VoskRecognitionListener listener) {
+        voskRecognitionListener = listener;
+    }
+
+    @Override
+    public void setPause(boolean paused) {
+        if (speechService != null) {
+            speechService.setPause(paused);
+        }
+    }
+
+    @Override
+    public void release() {
+        if (speechService != null) {
+            speechService.stop();
+            speechService.shutdown();
+        }
+
+        if (speechStreamService != null) {
+            speechStreamService.stop();
+        }
+    }
+}

BIN
vosk/src/main/models/assets/model-en-us/am.png


BIN
vosk/src/main/models/assets/model-en-us/conf.png


+ 7 - 0
vosk/src/main/models/assets/model-en-us/conf/mfcc.conf

@@ -0,0 +1,7 @@
+#--sample-frequency=8000
+--use-energy=false
+--num-mel-bins=40
+--num-ceps=40
+--low-freq=20
+--high-freq=7600
+--allow-downsample=true

+ 10 - 0
vosk/src/main/models/assets/model-en-us/conf/model.conf

@@ -0,0 +1,10 @@
+--min-active=200
+--max-active=3000
+--beam=10.0
+--lattice-beam=2.0
+--acoustic-scale=1.0
+--frame-subsampling-factor=3
+--endpoint.silence-phones=1:2:3:4:5:6:7:8:9:10
+--endpoint.rule2.min-trailing-silence=0.5
+--endpoint.rule3.min-trailing-silence=0.75
+--endpoint.rule4.min-trailing-silence=1.0

BIN
vosk/src/main/models/assets/model-en-us/files_need.png


BIN
vosk/src/main/models/assets/model-en-us/graph.png


BIN
vosk/src/main/models/assets/model-en-us/ivector.png


+ 0 - 0
vosk/src/main/models/assets/model-en-us/log.txt


+ 6 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/README

@@ -0,0 +1,6 @@
+Chinese Vosk model for mobile
+
+CER results
+
+23.54% speechio_02
+38.29% speechio_06

BIN
vosk/src/main/models/assets/vosk-model-small-cn-0.22/am/final.mdl


+ 8 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/conf/mfcc.conf

@@ -0,0 +1,8 @@
+--use-energy=false
+--sample-frequency=16000
+--num-mel-bins=40
+--num-ceps=40
+--low-freq=40
+--high-freq=-200
+--allow-upsample=true
+--allow-downsample=true

+ 10 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/conf/model.conf

@@ -0,0 +1,10 @@
+--min-active=200
+--max-active=5000
+--beam=12.0
+--lattice-beam=4.0
+--acoustic-scale=1.0
+--frame-subsampling-factor=3
+--endpoint.silence-phones=1:2:3:4:5:6:7:8:9:10
+--endpoint.rule2.min-trailing-silence=0.5
+--endpoint.rule3.min-trailing-silence=1.0
+--endpoint.rule4.min-trailing-silence=2.0

BIN
vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/Gr.fst


BIN
vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/HCLr.fst


+ 39 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/disambig_tid.int

@@ -0,0 +1,39 @@
+11845
+11846
+11847
+11848
+11849
+11850
+11851
+11852
+11853
+11854
+11855
+11856
+11857
+11858
+11859
+11860
+11861
+11862
+11863
+11864
+11865
+11866
+11867
+11868
+11869
+11870
+11871
+11872
+11873
+11874
+11875
+11876
+11877
+11878
+11879
+11880
+11881
+11882
+11883

+ 646 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/graph/phones/word_boundary.int

@@ -0,0 +1,646 @@
+1 nonword
+2 begin
+3 end
+4 internal
+5 singleton
+6 nonword
+7 begin
+8 end
+9 internal
+10 singleton
+11 begin
+12 end
+13 internal
+14 singleton
+15 begin
+16 end
+17 internal
+18 singleton
+19 begin
+20 end
+21 internal
+22 singleton
+23 begin
+24 end
+25 internal
+26 singleton
+27 begin
+28 end
+29 internal
+30 singleton
+31 begin
+32 end
+33 internal
+34 singleton
+35 begin
+36 end
+37 internal
+38 singleton
+39 begin
+40 end
+41 internal
+42 singleton
+43 begin
+44 end
+45 internal
+46 singleton
+47 begin
+48 end
+49 internal
+50 singleton
+51 begin
+52 end
+53 internal
+54 singleton
+55 begin
+56 end
+57 internal
+58 singleton
+59 begin
+60 end
+61 internal
+62 singleton
+63 begin
+64 end
+65 internal
+66 singleton
+67 begin
+68 end
+69 internal
+70 singleton
+71 begin
+72 end
+73 internal
+74 singleton
+75 begin
+76 end
+77 internal
+78 singleton
+79 begin
+80 end
+81 internal
+82 singleton
+83 begin
+84 end
+85 internal
+86 singleton
+87 begin
+88 end
+89 internal
+90 singleton
+91 begin
+92 end
+93 internal
+94 singleton
+95 begin
+96 end
+97 internal
+98 singleton
+99 begin
+100 end
+101 internal
+102 singleton
+103 begin
+104 end
+105 internal
+106 singleton
+107 begin
+108 end
+109 internal
+110 singleton
+111 begin
+112 end
+113 internal
+114 singleton
+115 begin
+116 end
+117 internal
+118 singleton
+119 begin
+120 end
+121 internal
+122 singleton
+123 begin
+124 end
+125 internal
+126 singleton
+127 begin
+128 end
+129 internal
+130 singleton
+131 begin
+132 end
+133 internal
+134 singleton
+135 begin
+136 end
+137 internal
+138 singleton
+139 begin
+140 end
+141 internal
+142 singleton
+143 begin
+144 end
+145 internal
+146 singleton
+147 begin
+148 end
+149 internal
+150 singleton
+151 begin
+152 end
+153 internal
+154 singleton
+155 begin
+156 end
+157 internal
+158 singleton
+159 begin
+160 end
+161 internal
+162 singleton
+163 begin
+164 end
+165 internal
+166 singleton
+167 begin
+168 end
+169 internal
+170 singleton
+171 begin
+172 end
+173 internal
+174 singleton
+175 begin
+176 end
+177 internal
+178 singleton
+179 begin
+180 end
+181 internal
+182 singleton
+183 begin
+184 end
+185 internal
+186 singleton
+187 begin
+188 end
+189 internal
+190 singleton
+191 begin
+192 end
+193 internal
+194 singleton
+195 begin
+196 end
+197 internal
+198 singleton
+199 begin
+200 end
+201 internal
+202 singleton
+203 begin
+204 end
+205 internal
+206 singleton
+207 begin
+208 end
+209 internal
+210 singleton
+211 begin
+212 end
+213 internal
+214 singleton
+215 begin
+216 end
+217 internal
+218 singleton
+219 begin
+220 end
+221 internal
+222 singleton
+223 begin
+224 end
+225 internal
+226 singleton
+227 begin
+228 end
+229 internal
+230 singleton
+231 begin
+232 end
+233 internal
+234 singleton
+235 begin
+236 end
+237 internal
+238 singleton
+239 begin
+240 end
+241 internal
+242 singleton
+243 begin
+244 end
+245 internal
+246 singleton
+247 begin
+248 end
+249 internal
+250 singleton
+251 begin
+252 end
+253 internal
+254 singleton
+255 begin
+256 end
+257 internal
+258 singleton
+259 begin
+260 end
+261 internal
+262 singleton
+263 begin
+264 end
+265 internal
+266 singleton
+267 begin
+268 end
+269 internal
+270 singleton
+271 begin
+272 end
+273 internal
+274 singleton
+275 begin
+276 end
+277 internal
+278 singleton
+279 begin
+280 end
+281 internal
+282 singleton
+283 begin
+284 end
+285 internal
+286 singleton
+287 begin
+288 end
+289 internal
+290 singleton
+291 begin
+292 end
+293 internal
+294 singleton
+295 begin
+296 end
+297 internal
+298 singleton
+299 begin
+300 end
+301 internal
+302 singleton
+303 begin
+304 end
+305 internal
+306 singleton
+307 begin
+308 end
+309 internal
+310 singleton
+311 begin
+312 end
+313 internal
+314 singleton
+315 begin
+316 end
+317 internal
+318 singleton
+319 begin
+320 end
+321 internal
+322 singleton
+323 begin
+324 end
+325 internal
+326 singleton
+327 begin
+328 end
+329 internal
+330 singleton
+331 begin
+332 end
+333 internal
+334 singleton
+335 begin
+336 end
+337 internal
+338 singleton
+339 begin
+340 end
+341 internal
+342 singleton
+343 begin
+344 end
+345 internal
+346 singleton
+347 begin
+348 end
+349 internal
+350 singleton
+351 begin
+352 end
+353 internal
+354 singleton
+355 begin
+356 end
+357 internal
+358 singleton
+359 begin
+360 end
+361 internal
+362 singleton
+363 begin
+364 end
+365 internal
+366 singleton
+367 begin
+368 end
+369 internal
+370 singleton
+371 begin
+372 end
+373 internal
+374 singleton
+375 begin
+376 end
+377 internal
+378 singleton
+379 begin
+380 end
+381 internal
+382 singleton
+383 begin
+384 end
+385 internal
+386 singleton
+387 begin
+388 end
+389 internal
+390 singleton
+391 begin
+392 end
+393 internal
+394 singleton
+395 begin
+396 end
+397 internal
+398 singleton
+399 begin
+400 end
+401 internal
+402 singleton
+403 begin
+404 end
+405 internal
+406 singleton
+407 begin
+408 end
+409 internal
+410 singleton
+411 begin
+412 end
+413 internal
+414 singleton
+415 begin
+416 end
+417 internal
+418 singleton
+419 begin
+420 end
+421 internal
+422 singleton
+423 begin
+424 end
+425 internal
+426 singleton
+427 begin
+428 end
+429 internal
+430 singleton
+431 begin
+432 end
+433 internal
+434 singleton
+435 begin
+436 end
+437 internal
+438 singleton
+439 begin
+440 end
+441 internal
+442 singleton
+443 begin
+444 end
+445 internal
+446 singleton
+447 begin
+448 end
+449 internal
+450 singleton
+451 begin
+452 end
+453 internal
+454 singleton
+455 begin
+456 end
+457 internal
+458 singleton
+459 begin
+460 end
+461 internal
+462 singleton
+463 begin
+464 end
+465 internal
+466 singleton
+467 begin
+468 end
+469 internal
+470 singleton
+471 begin
+472 end
+473 internal
+474 singleton
+475 begin
+476 end
+477 internal
+478 singleton
+479 begin
+480 end
+481 internal
+482 singleton
+483 begin
+484 end
+485 internal
+486 singleton
+487 begin
+488 end
+489 internal
+490 singleton
+491 begin
+492 end
+493 internal
+494 singleton
+495 begin
+496 end
+497 internal
+498 singleton
+499 begin
+500 end
+501 internal
+502 singleton
+503 begin
+504 end
+505 internal
+506 singleton
+507 begin
+508 end
+509 internal
+510 singleton
+511 begin
+512 end
+513 internal
+514 singleton
+515 begin
+516 end
+517 internal
+518 singleton
+519 begin
+520 end
+521 internal
+522 singleton
+523 begin
+524 end
+525 internal
+526 singleton
+527 begin
+528 end
+529 internal
+530 singleton
+531 begin
+532 end
+533 internal
+534 singleton
+535 begin
+536 end
+537 internal
+538 singleton
+539 begin
+540 end
+541 internal
+542 singleton
+543 begin
+544 end
+545 internal
+546 singleton
+547 begin
+548 end
+549 internal
+550 singleton
+551 begin
+552 end
+553 internal
+554 singleton
+555 begin
+556 end
+557 internal
+558 singleton
+559 begin
+560 end
+561 internal
+562 singleton
+563 begin
+564 end
+565 internal
+566 singleton
+567 begin
+568 end
+569 internal
+570 singleton
+571 begin
+572 end
+573 internal
+574 singleton
+575 begin
+576 end
+577 internal
+578 singleton
+579 begin
+580 end
+581 internal
+582 singleton
+583 begin
+584 end
+585 internal
+586 singleton
+587 begin
+588 end
+589 internal
+590 singleton
+591 begin
+592 end
+593 internal
+594 singleton
+595 begin
+596 end
+597 internal
+598 singleton
+599 begin
+600 end
+601 internal
+602 singleton
+603 begin
+604 end
+605 internal
+606 singleton
+607 begin
+608 end
+609 internal
+610 singleton
+611 begin
+612 end
+613 internal
+614 singleton
+615 begin
+616 end
+617 internal
+618 singleton
+619 begin
+620 end
+621 internal
+622 singleton
+623 begin
+624 end
+625 internal
+626 singleton
+627 begin
+628 end
+629 internal
+630 singleton
+631 begin
+632 end
+633 internal
+634 singleton
+635 begin
+636 end
+637 internal
+638 singleton
+639 begin
+640 end
+641 internal
+642 singleton
+643 begin
+644 end
+645 internal
+646 singleton

BIN
vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/final.dubm


BIN
vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/final.ie


BIN
vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/final.mat


File diff suppressed because it is too large
+ 3 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/global_cmvn.stats


+ 0 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/online_cmvn.conf


+ 2 - 0
vosk/src/main/models/assets/vosk-model-small-cn-0.22/ivector/splice.conf

@@ -0,0 +1,2 @@
+--left-context=3
+--right-context=3