@mentra/bluetooth-sdk 3.3.0 → 3.4.0-beta.1241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/MIGRATION.md +61 -0
  2. package/README.md +80 -11
  3. package/android/build.gradle +60 -51
  4. package/android/gradle.properties +3 -0
  5. package/android/settings.gradle +47 -3
  6. package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
  7. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -2
  8. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +85 -6
  9. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +35 -1
  10. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +154 -110
  11. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +21 -0
  12. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +1 -0
  13. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
  14. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +27 -2
  15. package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +5 -0
  16. package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
  17. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicy.kt +64 -0
  18. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +925 -155
  19. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +227 -0
  20. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +19 -0
  21. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicy.kt +94 -0
  22. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachine.kt +411 -0
  23. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateStore.kt +124 -0
  24. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +54 -59
  25. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +5 -32
  26. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasEncoder.kt +8 -1
  27. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +3 -10
  28. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
  29. package/android/src/main/java/com/mentra/bluetoothsdk/status/DeviceStatus.kt +50 -0
  30. package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
  31. package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
  32. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
  33. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
  34. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
  35. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
  36. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
  37. package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
  38. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
  39. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
  40. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
  41. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
  42. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
  43. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
  44. package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
  45. package/android/src/test/java/com/mentra/bluetoothsdk/DeviceManagerOwnerLossTest.kt +146 -0
  46. package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusAudioSetupTest.kt +51 -0
  47. package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusClassicAudioTest.kt +2 -0
  48. package/android/src/test/java/com/mentra/bluetoothsdk/WifiAdbPeerIntentTest.kt +19 -0
  49. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicyTest.kt +65 -0
  50. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveAudioSetupReadinessTest.kt +231 -0
  51. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +5 -1
  52. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
  53. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +368 -0
  54. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +20 -0
  55. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicyTest.kt +136 -0
  56. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachineTest.kt +346 -0
  57. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
  58. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
  59. package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
  60. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
  61. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
  62. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
  63. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
  64. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
  65. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
  66. package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
  67. package/build/BluetoothSdk.types.d.ts +201 -1
  68. package/build/BluetoothSdk.types.d.ts.map +1 -1
  69. package/build/BluetoothSdk.types.js.map +1 -1
  70. package/build/_private/BluetoothSdkModule.d.ts +43 -5
  71. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  72. package/build/_private/BluetoothSdkModule.js +2 -0
  73. package/build/_private/BluetoothSdkModule.js.map +1 -1
  74. package/build/generated/changelogCatalog.d.ts +3 -0
  75. package/build/generated/changelogCatalog.d.ts.map +1 -1
  76. package/build/generated/changelogCatalog.js +4 -0
  77. package/build/generated/changelogCatalog.js.map +1 -1
  78. package/build/generated/releaseMetadata.js +6 -6
  79. package/build/generated/releaseMetadata.js.map +1 -1
  80. package/build/index.d.ts +1 -1
  81. package/build/index.d.ts.map +1 -1
  82. package/build/index.js +9 -0
  83. package/build/index.js.map +1 -1
  84. package/ios/BluetoothSdkModule.swift +76 -12
  85. package/ios/MentraBluetoothSDK.podspec +4 -0
  86. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
  87. package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
  88. package/ios/Source/BesCrashReportWaiters.swift +64 -0
  89. package/ios/Source/BluetoothSdkDefaults.swift +2 -2
  90. package/ios/Source/Bridge.swift +11 -3
  91. package/ios/Source/DeviceManager.swift +131 -18
  92. package/ios/Source/DeviceStore.swift +27 -0
  93. package/ios/Source/GeneratedChangelogCatalog.swift +1 -0
  94. package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
  95. package/ios/Source/MentraBluetoothSDK.swift +40 -5
  96. package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
  97. package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
  98. package/ios/Source/audio/SpeechActivity.swift +277 -0
  99. package/ios/Source/errors/BluetoothSdkError.swift +5 -1
  100. package/ios/Source/events/BluetoothEvents.swift +41 -0
  101. package/ios/Source/internal/BleTraceLogger.swift +9 -6
  102. package/ios/Source/internal/BluetoothAvailability.swift +15 -5
  103. package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +186 -0
  104. package/ios/Source/sgcs/MentraLive.swift +1270 -189
  105. package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +260 -1
  106. package/ios/Source/sgcs/MentraLivePairingStateMachine.swift +385 -0
  107. package/ios/Source/sgcs/MentraLivePairingStateStore.swift +121 -0
  108. package/ios/Source/sgcs/Nimo.swift +10 -3
  109. package/ios/Source/sgcs/NimoCanvasCoordinator.swift +39 -9
  110. package/ios/Source/sgcs/SGCManager.swift +13 -0
  111. package/ios/Source/sgcs/Simulated.swift +2 -0
  112. package/ios/Source/status/DeviceStatus.swift +35 -0
  113. package/ios/Source/stt/STTTools.swift +13 -31
  114. package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
  115. package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
  116. package/ios/Source/stt/WakeWordDetector.swift +145 -0
  117. package/ios/Source/types/DeviceModels.swift +8 -1
  118. package/ios/Source/utils/AudioSessionMonitor.swift +158 -5
  119. package/ios/Source/utils/BoundedWait.swift +44 -0
  120. package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
  121. package/ios/Source/utils/SttModelTraits.swift +62 -0
  122. package/ios/Tests/BesCrashReportTests.swift +142 -0
  123. package/ios/Tests/BluetoothAudioRouteTests.swift +82 -0
  124. package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
  125. package/ios/Tests/DeviceManagerReconnectTests.swift +4 -2
  126. package/ios/Tests/GlassesAudioSetupPolicyTests.swift +197 -0
  127. package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
  128. package/ios/Tests/MentraLiveAudioSetupTests.swift +209 -0
  129. package/ios/Tests/MentraLiveConnectionOptionsTests.swift +55 -0
  130. package/ios/Tests/MentraLivePairingAdvertisementTests.swift +327 -0
  131. package/ios/Tests/MentraLivePairingStateMachineTests.swift +402 -0
  132. package/ios/Tests/MentraLiveSessionReadinessTests.swift +368 -26
  133. package/ios/Tests/NimoCanvasTransportTests.swift +58 -0
  134. package/ios/Tests/PcmStreamTests.swift +299 -0
  135. package/ios/Tests/SpeechActivityTests.swift +238 -0
  136. package/ios/Tests/SttModelTraitsTests.swift +62 -0
  137. package/ios/Tests/WifiAdbDispatchTests.swift +118 -0
  138. package/package.json +3 -2
  139. package/plugin/build/withAndroid.js +9 -11
  140. package/plugin/build/withKotlinVersion.d.ts +2 -0
  141. package/plugin/build/withKotlinVersion.js +46 -0
  142. package/src/BluetoothSdk.types.ts +201 -1
  143. package/src/_private/BluetoothSdkModule.ts +47 -5
  144. package/src/generated/changelogCatalog.ts +4 -0
  145. package/src/generated/releaseMetadata.ts +6 -6
  146. package/src/index.ts +22 -0
  147. package/android/silero/LICENSE.md +0 -17
  148. package/android/silero/build.gradle +0 -50
  149. package/android/silero/proguard-rules.pro +0 -24
  150. package/android/silero/src/androidTest/assets/hello.wav +0 -0
  151. package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
  152. package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
  153. package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
  154. package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
  155. package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
  156. package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
  157. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
  158. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
  159. package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
  160. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
  161. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
  162. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
  163. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
  164. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
  165. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
  166. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -288
  167. /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
  168. /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
@@ -11,10 +11,10 @@ export interface BluetoothSdkReleaseMetadata {
11
11
 
12
12
  export const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
- "familyBaseVersion": "3.3.0",
15
- "releaseIdentity": "3.3.0",
16
- "releaseSetId": "mentra-3.3.0",
17
- "sourceCommit": "5bd50400b076b758691429755b6e1bd7b77268fb",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-beta.1188.json",
19
- "otaManifestSha256": "66070872d18ee11303347e1be71b7385af96aab30adc3d226ceb4a82c2c4848f"
14
+ "familyBaseVersion": "3.4.0",
15
+ "releaseIdentity": "3.4.0-beta.1241",
16
+ "releaseSetId": "mentra-3.4.0-beta.1241",
17
+ "sourceCommit": "3654f26c298086be9dcf338487354ec5847c9147",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1241.json",
19
+ "otaManifestSha256": "80fb91c7dbb2a4e21b8612d487ce988bf957d4d2dec21c436ab66c6748d190d7"
20
20
  })
package/src/index.ts CHANGED
@@ -26,6 +26,8 @@ const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
26
26
  "speaking_status",
27
27
  "battery_status",
28
28
  "local_transcription",
29
+ "wake_word",
30
+ "speech_activity",
29
31
  "wifi_status_change",
30
32
  "wifi_scan_result",
31
33
  "wifi_forget_result",
@@ -47,6 +49,9 @@ const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
47
49
  "pair_failure",
48
50
  "pairing_info",
49
51
  "entering_pairing_mode",
52
+ "pairing_mode_ended",
53
+ "pairing_state_changed",
54
+ "audio_setup_changed",
50
55
  "owner_replaced",
51
56
  "audio_pairing_needed",
52
57
  "audio_connected",
@@ -60,6 +65,7 @@ const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
60
65
  "ota_start_ack",
61
66
  "ota_status",
62
67
  "ar99_ota_status",
68
+ "bes_crash_detected",
63
69
  "version_info",
64
70
  "extraction_progress",
65
71
  ])
@@ -188,7 +194,10 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
188
194
  checkSttModelAvailable: bindPublicMethod("checkSttModelAvailable"),
189
195
  validateSttModel: bindPublicMethod("validateSttModel"),
190
196
  extractTarBz2: bindPublicMethod("extractTarBz2"),
197
+ setWakeWordDetection: bindPublicMethod("setWakeWordDetection"),
198
+ finishTranscription: bindPublicMethod("finishTranscription"),
191
199
  restartTranscriber: bindPublicMethod("restartTranscriber"),
200
+ setSpeechActivityDetection: bindPublicMethod("setSpeechActivityDetection"),
192
201
  setTtsModelDetails: bindPublicMethod("setTtsModelDetails"),
193
202
  getTtsModelPath: bindPublicMethod("getTtsModelPath"),
194
203
  getTtsModelLanguage: bindPublicMethod("getTtsModelLanguage"),
@@ -218,6 +227,10 @@ export type {
218
227
  AudioDisconnectedEvent,
219
228
  AudioPairingNeededEvent,
220
229
  BatteryStatusEvent,
230
+ BesCrashDetectedEvent,
231
+ BesCrashEviction,
232
+ BesCrashIncidentState,
233
+ BesCrashSummary,
221
234
  BluetoothSdkEvent,
222
235
  BluetoothSdkEventListener,
223
236
  BluetoothSdkEventMap,
@@ -250,6 +263,8 @@ export type {
250
263
  GlassesSessionChangedEvent,
251
264
  KeepAliveAckEvent,
252
265
  LocalTranscriptionEvent,
266
+ WakeWordEvent,
267
+ SpeechActivityEvent,
253
268
  LogEvent,
254
269
  MicLc3Event,
255
270
  MicHealthEvent,
@@ -266,9 +281,16 @@ export type {
266
281
  OtaUpdateInfo,
267
282
  ReleaseChangelog,
268
283
  MtkUpdateCompleteEvent,
284
+ PairFailureCode,
269
285
  PairFailureEvent,
270
286
  PairingInfoEvent,
271
287
  EnteringPairingModeEvent,
288
+ MentraLivePairingState,
289
+ PairingModeEndedEvent,
290
+ PairingModeEndedReason,
291
+ PairingStateChangedEvent,
292
+ GlassesAudioSetupState,
293
+ AudioSetupChangedEvent,
272
294
  OwnerReplacedEvent,
273
295
  PhotoCaptureMetadata,
274
296
  PhotoResolvedConfig,
@@ -1,17 +0,0 @@
1
- Copyright 2023 Georgiy Konovalov
2
-
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5
- associated documentation files (the "Software"), to deal in the Software without restriction,
6
- including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
- and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
8
- subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all copies or substantial
11
- portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14
- NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,50 +0,0 @@
1
- // Vendored from https://github.com/gkonovalov/android-vad (silero module, v2.0.10)
2
- // Consumed in-place by the bluetooth-sdk so we can pin ORT to a version that
3
- // matches our other ORT consumer (sherpa-onnx) without depending on a Jitpack
4
- // AAR whose prebuilt JNI was built against a different ORT.
5
- plugins {
6
- id 'com.android.library'
7
- id 'kotlin-android'
8
- }
9
-
10
- android {
11
- namespace "com.konovalov.vad.silero"
12
- compileSdk 36
13
-
14
- defaultConfig {
15
- minSdkVersion 24
16
- targetSdkVersion 36
17
-
18
- ndk {
19
- // Honor reactNativeArchitectures (dev CI is arm64-only; staging
20
- // production sets all four ABIs) so this module does not keep
21
- // compiling every ABI on a filtered build.
22
- def abiList = (findProperty("reactNativeArchitectures") ?: "armeabi-v7a,arm64-v8a,x86,x86_64")
23
- .toString()
24
- .split(",")
25
- .collect { it.trim() }
26
- .findAll { !it.isEmpty() }
27
- abiFilters(*abiList)
28
- }
29
- }
30
-
31
- aaptOptions {
32
- noCompress "onnx"
33
- }
34
-
35
- compileOptions {
36
- sourceCompatibility JavaVersion.VERSION_17
37
- targetCompatibility JavaVersion.VERSION_17
38
- }
39
-
40
- kotlinOptions {
41
- jvmTarget = '17'
42
- }
43
- }
44
-
45
- dependencies {
46
- // 1.24.3 matches the ORT version sherpa-onnx 1.13.2 was built against, so
47
- // both consumers can share a single libonnxruntime.so (same versioned
48
- // OrtGetApiBase@@VERS_1.24.3 symbol). Keep these versions in lockstep.
49
- implementation 'com.microsoft.onnxruntime:onnxruntime-android:1.24.3'
50
- }
@@ -1,24 +0,0 @@
1
- # Add project specific ProGuard rules here.
2
- # You can control the set of applied configuration files using the
3
- # proguardFiles setting in build.gradle.
4
- #
5
- # For more details, see
6
- # http://developer.android.com/guide/developing/tools/proguard.html
7
-
8
- # If your project uses WebView with JS, uncomment the following
9
- # and specify the fully qualified class name to the JavaScript interface
10
- # class:
11
- #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12
- # public *;
13
- #}
14
-
15
- # Uncomment this to preserve the line number information for
16
- # debugging stack traces.
17
- #-keepattributes SourceFile,LineNumberTable
18
-
19
- # If you keep the line number information, uncomment this to
20
- # hide the original source file name.
21
- #-renamesourcefileattribute SourceFile
22
- -keep class ai.onnxruntime.** {*;}
23
- -keep class com.konovalov.vad.** {*;}
24
- -dontwarn com.google.**
@@ -1,79 +0,0 @@
1
- package com.konovalov.silero
2
-
3
- import android.content.Context
4
- import androidx.test.ext.junit.runners.AndroidJUnit4
5
- import androidx.test.platform.app.InstrumentationRegistry
6
- import com.konovalov.vad.silero.Vad
7
- import com.konovalov.vad.silero.VadSilero
8
- import com.konovalov.vad.silero.config.FrameSize
9
- import com.konovalov.vad.silero.config.Mode
10
- import com.konovalov.vad.silero.config.SampleRate
11
- import junit.framework.TestCase.assertEquals
12
- import org.junit.After
13
- import org.junit.Before
14
- import org.junit.Test
15
- import org.junit.runner.RunWith
16
-
17
-
18
- /**
19
- * Created by Georgiy Konovalov on 12/22/2023.
20
- *
21
- * Instrumented test for VadSilero class.
22
- */
23
- @RunWith(AndroidJUnit4::class)
24
- class VadSileroTest {
25
-
26
- private lateinit var vad: VadSilero
27
- private lateinit var testContext: Context
28
-
29
- @Before
30
- fun setUp() {
31
- this.testContext = InstrumentationRegistry.getInstrumentation().context
32
-
33
- this.vad = Vad.builder()
34
- .setContext(testContext)
35
- .setSampleRate(SampleRate.SAMPLE_RATE_16K)
36
- .setFrameSize(FrameSize.FRAME_SIZE_512)
37
- .setMode(Mode.VERY_AGGRESSIVE)
38
- .build()
39
- }
40
-
41
- @After
42
- fun shutdown() {
43
- vad.close()
44
- }
45
-
46
- @Test
47
- fun testIsSpeech() {
48
- // List for VAD results
49
- val actualResult = mutableListOf<Boolean>()
50
-
51
- // List with expected VAD results
52
- val expectedResult = listOf(
53
- false, false, false, false, false,
54
- false, true, true, true, true,
55
- true, true, true, true, true,
56
- true, true, true, false, false
57
- )
58
-
59
- // Buffer size should be 2x for ByteArray
60
- val chunkSize = vad.frameSize.value * 2
61
-
62
- // Reading audio data from test file
63
- testContext.assets.open("hello.wav").buffered().use { input ->
64
- // Skip WAV Header
65
- input.skip(44)
66
-
67
- while (input.available() > 0) {
68
- // Read audio Frame
69
- val frameChunk = ByteArray(chunkSize).apply { input.read(this) }
70
-
71
- // Save interference result
72
- actualResult.add(vad.isSpeech(frameChunk))
73
- }
74
- }
75
-
76
- // Compare expectedResult with actualResult
77
- assertEquals(expectedResult, actualResult)
78
- }
79
- }
@@ -1,160 +0,0 @@
1
- package com.konovalov.vad.silero
2
-
3
- import android.content.Context
4
- import com.konovalov.vad.silero.config.FrameSize
5
- import com.konovalov.vad.silero.config.Mode
6
- import com.konovalov.vad.silero.config.SampleRate
7
-
8
- /**
9
- * Created by Georgiy Konovalov on 6/26/2023.
10
- *
11
- * The Silero VAD algorithm, based on DNN, analyzes the audio signal to determine whether it
12
- * contains speech or non-speech segments. It offers higher accuracy in differentiating speech from
13
- * background noise compared to the WebRTC VAD algorithm.
14
- *
15
- * The Silero VAD supports the following parameters:
16
- *
17
- * Sample Rates:
18
- *
19
- * 8000Hz,
20
- * 16000Hz
21
- *
22
- * Frame Sizes (per sample rate):
23
- *
24
- * For 8000Hz: 80, 160, 240
25
- * For 16000Hz: 160, 320, 480
26
- *
27
- * Mode:
28
- *
29
- * NORMAL,
30
- * LOW_BITRATE,
31
- * AGGRESSIVE,
32
- * VERY_AGGRESSIVE
33
- *
34
- * Please note that the VAD class supports these specific combinations of sample
35
- * rates and frame sizes, and the classifiers determine the aggressiveness of the voice
36
- * activity detection algorithm.
37
- *
38
- * @param context is required for reading the model file from file system.
39
- * @param sampleRate is required for processing audio input.
40
- * @param frameSize is required for processing audio input.
41
- * @param mode is required for the VAD model.
42
- * @param speechDurationMs is minimum duration in milliseconds for speech segments (optional).
43
- * @param silenceDurationMs is minimum duration in milliseconds for silence segments (optional).
44
- */
45
- class Vad private constructor() {
46
- private lateinit var context: Context
47
- private lateinit var sampleRate: SampleRate
48
- private lateinit var frameSize: FrameSize
49
- private lateinit var mode: Mode
50
- private var speechDurationMs = 0
51
- private var silenceDurationMs = 0
52
-
53
- /**
54
- * Set Context for Vad Model.
55
- *
56
- * @param context is required for accessing the model file.
57
- */
58
- fun setContext(context: Context): Vad = apply {
59
- this.context = context.applicationContext ?: context
60
- }
61
-
62
- /**
63
- * Set, retrieve and validate sample rate for Vad Model.
64
- *
65
- * Valid Sample Rates:
66
- *
67
- * 8000Hz,
68
- * 16000Hz
69
- *
70
- * @param sampleRate is required for processing audio input.
71
- */
72
- fun setSampleRate(sampleRate: SampleRate): Vad = apply {
73
- this.sampleRate = sampleRate
74
- }
75
-
76
- /**
77
- * Set, retrieve and validate frame size for Vad Model.
78
- *
79
- * Valid Frame Sizes (per sample rate):
80
- *
81
- * For 8000Hz: 256, 512, 768
82
- * For 16000Hz: 512, 1024, 1536
83
- *
84
- * @param frameSize is required for processing audio input.
85
- */
86
- fun setFrameSize(frameSize: FrameSize): Vad = apply {
87
- this.frameSize = frameSize
88
- }
89
-
90
- /**
91
- * Set and retrieve detection mode for Vad model.
92
- *
93
- * Mode:
94
- *
95
- * NORMAL,
96
- * LOW_BITRATE,
97
- * AGGRESSIVE,
98
- * VERY_AGGRESSIVE
99
- *
100
- * @param mode is required for the VAD model.
101
- */
102
- fun setMode(mode: Mode): Vad = apply {
103
- this.mode = mode
104
- }
105
-
106
- /**
107
- * Set the minimum duration in milliseconds for speech segments.
108
- * The value of this parameter will define the necessary and sufficient duration of positive
109
- * results to recognize result as speech. This parameter is optional.
110
- *
111
- * Permitted range (0ms >= speechDurationMs <= 300000ms).
112
- *
113
- * Parameters used for {@link VadSilero.isSpeech}.
114
- *
115
- * @param speechDurationMs minimum duration in milliseconds for speech segments.
116
- */
117
- fun setSpeechDurationMs(speechDurationMs: Int): Vad = apply {
118
- this.speechDurationMs = speechDurationMs
119
- }
120
-
121
- /**
122
- * Set the minimum duration in milliseconds for silence segments.
123
- * The value of this parameter will define the necessary and sufficient duration of
124
- * negative results to recognize it as silence. This parameter is optional.
125
- *
126
- * Permitted range (0ms >= silenceDurationMs <= 300000ms).
127
- *
128
- * Parameters used in {@link VadSilero.isSpeech}.
129
- *
130
- * @param silenceDurationMs minimum duration in milliseconds for silence segments.
131
- */
132
- fun setSilenceDurationMs(silenceDurationMs: Int): Vad = apply {
133
- this.silenceDurationMs = silenceDurationMs
134
- }
135
-
136
- /**
137
- * Builds and returns a VadModel instance based on the specified parameters.
138
- *
139
- * @return constructed VadSilero model.
140
- * @throws IllegalArgumentException if invalid parameters have been set for the model.
141
- * @throws OrtException if the model failed to parse, wasn't compatible or caused an error.
142
- */
143
- fun build(): VadSilero {
144
- return VadSilero(
145
- context,
146
- sampleRate,
147
- frameSize,
148
- mode,
149
- speechDurationMs,
150
- silenceDurationMs
151
- )
152
- }
153
-
154
- companion object {
155
- @JvmStatic
156
- fun builder(): Vad {
157
- return Vad()
158
- }
159
- }
160
- }