@mentra/bluetooth-sdk 3.4.0-dev.999 → 3.4.1-beta.1409
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.
- package/MIGRATION.md +16 -7
- package/README.md +41 -14
- package/android/build.gradle +60 -51
- package/android/gradle.properties +3 -0
- package/android/settings.gradle +47 -3
- package/android/src/main/assets/nimo/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +77 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +41 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +131 -122
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +3 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +31 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +57 -196
- package/android/src/main/java/com/mentra/bluetoothsdk/OtaManifest.kt +1 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/debug/BleTraceLogger.kt +10 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/Ipv4Prefix.kt +51 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/NetworkFacts.kt +81 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkError.kt +108 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadiness.kt +103 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpec.kt +44 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkState.kt +117 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/ScopedSoftApNetwork.kt +598 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/hotspot/SoftApTrace.kt +143 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +0 -7
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTracker.kt +15 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +308 -60
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +14 -5
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +210 -325
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdater.kt +213 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocol.kt +112 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/streaming/StreamModels.kt +17 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/StreamRequestCaptureAudioTest.kt +23 -4
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/Ipv4PrefixTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/NetworkFactsTest.kt +59 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedLocalNetworkPermissionTest.kt +35 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkErrorTest.kt +85 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkLifecycleTest.kt +164 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkReadinessTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/ScopedNetworkRequestSpecTest.kt +56 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/SoftApTraceTest.kt +97 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/hotspot/UnavailableRetryTest.kt +47 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/ClassicAudioConnectionTrackerTest.kt +26 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +141 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicyTest.kt +9 -3
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveRgbLedResponseTest.kt +76 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareTargetTest.kt +15 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoFirmwareUpdaterTest.kt +76 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoOtaProtocolTest.kt +77 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoReadinessDriverTest.kt +31 -1
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
- package/build/BluetoothSdk.types.d.ts +103 -5
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +42 -8
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +1 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts +1 -1
- package/build/_private/MentraLocalNetworkModule.d.ts.map +1 -1
- package/build/_private/MentraLocalNetworkModule.js.map +1 -1
- package/build/generated/changelogCatalog.d.ts +5 -2
- package/build/generated/changelogCatalog.d.ts.map +1 -1
- package/build/generated/changelogCatalog.js +6 -2
- package/build/generated/changelogCatalog.js.map +1 -1
- package/build/generated/releaseMetadata.js +6 -6
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.d.ts +0 -2
- package/build/ota-server/MentraOtaServerModule.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.js.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts +0 -1
- package/build/ota-server/MentraOtaServerModule.web.d.ts.map +1 -1
- package/build/ota-server/MentraOtaServerModule.web.js +0 -3
- package/build/ota-server/MentraOtaServerModule.web.js.map +1 -1
- package/build/ota-transport/index.d.ts +3 -3
- package/build/ota-transport/index.d.ts.map +1 -1
- package/build/ota-transport/index.js +4 -4
- package/build/ota-transport/index.js.map +1 -1
- package/build/react/useGlassesConnection.d.ts +1 -1
- package/build/react/useGlassesConnection.d.ts.map +1 -1
- package/build/react/useGlassesConnection.js +3 -3
- package/build/react/useGlassesConnection.js.map +1 -1
- package/build/react/useMentraBluetooth.d.ts +1 -1
- package/build/react/useMentraBluetooth.d.ts.map +1 -1
- package/build/react/useMentraBluetooth.js +1 -1
- package/build/react/useMentraBluetooth.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +73 -22
- package/ios/LocalIPv4.swift +0 -61
- package/ios/MentraBluetoothSDK.podspec +7 -1
- package/ios/MentraOtaServerModule.swift +0 -16
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
- package/ios/Resources/NimoFirmware/nimo-firmware-0.1.1.1-537cf1.bin +0 -0
- package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
- package/ios/Source/BesCrashReportWaiters.swift +64 -0
- package/ios/Source/BluetoothSdkDefaults.swift +4 -4
- package/ios/Source/Bridge.swift +14 -0
- package/ios/Source/DeviceManager.swift +52 -22
- package/ios/Source/GeneratedChangelogCatalog.swift +3 -2
- package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
- package/ios/Source/MentraBluetoothSDK.swift +35 -16
- package/ios/Source/OtaManifest.swift +1 -17
- package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
- package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
- package/ios/Source/audio/SpeechActivity.swift +277 -0
- package/ios/Source/events/BluetoothEvents.swift +41 -0
- package/ios/Source/internal/BleTraceLogger.swift +14 -1
- package/ios/Source/internal/BluetoothAvailability.swift +15 -5
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
- package/ios/Source/sgcs/MentraLive.swift +207 -66
- package/ios/Source/sgcs/Nimo.swift +249 -276
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
- package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
- package/ios/Source/sgcs/NimoFirmwareUpdater.swift +260 -0
- package/ios/Source/sgcs/NimoOtaProtocol.swift +159 -0
- package/ios/Source/sgcs/SGCManager.swift +6 -0
- package/ios/Source/streaming/StreamModels.swift +15 -6
- package/ios/Source/stt/STTTools.swift +13 -31
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
- package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
- package/ios/Source/stt/WakeWordDetector.swift +145 -0
- package/ios/Source/utils/BoundedWait.swift +44 -0
- package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
- package/ios/Source/utils/SttModelTraits.swift +62 -0
- package/ios/Tests/BesCrashReportTests.swift +142 -0
- package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
- package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
- package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
- package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
- package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
- package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
- package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
- package/ios/Tests/NimoOtaProtocolTests.swift +78 -0
- package/ios/Tests/PcmStreamTests.swift +299 -0
- package/ios/Tests/SpeechActivityTests.swift +238 -0
- package/ios/Tests/StreamRequestTests.swift +18 -0
- package/ios/Tests/SttModelTraitsTests.swift +62 -0
- package/package.json +2 -2
- package/plugin/build/withAndroid.js +9 -11
- package/plugin/build/withKotlinVersion.d.ts +2 -0
- package/plugin/build/withKotlinVersion.js +46 -0
- package/src/BluetoothSdk.types.ts +107 -5
- package/src/_private/BluetoothSdkModule.ts +45 -8
- package/src/_private/MentraLocalNetworkModule.ts +5 -1
- package/src/generated/changelogCatalog.ts +6 -2
- package/src/generated/releaseMetadata.ts +6 -6
- package/src/index.ts +13 -1
- package/src/ota-server/MentraOtaServerModule.ts +0 -2
- package/src/ota-server/MentraOtaServerModule.web.ts +0 -4
- package/src/ota-transport/index.ts +4 -5
- package/src/react/useGlassesConnection.ts +4 -4
- package/src/react/useMentraBluetooth.ts +2 -2
- package/android/silero/LICENSE.md +0 -17
- package/android/silero/build.gradle +0 -50
- package/android/silero/proguard-rules.pro +0 -24
- package/android/silero/src/androidTest/assets/hello.wav +0 -0
- package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
- package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
- package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
- package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
- package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
- package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
- package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
- package/android/src/main/java/com/mentra/bluetoothsdk/ScopedNetworkReadiness.kt +0 -17
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
- package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
- package/android/src/test/java/com/mentra/bluetoothsdk/ScopedNetworkReadinessTest.kt +0 -39
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
- package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
- package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
- package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
- package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
- package/ios/Tests/NimoResourceSessionTests.swift +0 -476
- /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
- /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
|
@@ -93,13 +93,11 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
93
93
|
|
|
94
94
|
// Connection Commands
|
|
95
95
|
requestStatus(): Promise<void>
|
|
96
|
-
/** Mac-only explicit fixture launch. Strict nimo-macos-resource-v1 Codable
|
|
97
|
-
* request/receipt JSON; ordinary launches refuse. No packet/path commands. */
|
|
98
|
-
nimoResourceSession?(requestJSON: string): Promise<string>
|
|
99
96
|
connectDefault(options?: ConnectOptions): Promise<void>
|
|
100
97
|
connectDefaultWithOptions(options: Required<ConnectOptions>): Promise<void>
|
|
101
98
|
setDefaultDevice(device: Device | null): Promise<void>
|
|
102
|
-
|
|
99
|
+
/** Android only: iOS cannot read its Bluetooth bonds. */
|
|
100
|
+
getBondedGlasses?: () => Promise<{name: string; address: string} | null>
|
|
103
101
|
getScanDiagnostic?: (model: DeviceModel) => Promise<ScanDiagnostic | null>
|
|
104
102
|
startScan(model: DeviceModel): Promise<void>
|
|
105
103
|
stopScan(): Promise<void>
|
|
@@ -131,6 +129,12 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
131
129
|
|
|
132
130
|
// Incident Reporting
|
|
133
131
|
sendIncidentId(incidentId: string, apiBaseUrl?: string | null): Promise<void>
|
|
132
|
+
/**
|
|
133
|
+
* Tell Mentra Live that Cloud recorded `reportId` for the BES crash incident
|
|
134
|
+
* `incidentKey`. Resolves only on the glasses' matching `ok:true` ack; rejects
|
|
135
|
+
* on `ok:false`, disconnect, or after 10 s. Call `sendIncidentId` only after it resolves.
|
|
136
|
+
*/
|
|
137
|
+
sendBesCrashReported(incidentKey: string, reportId: string): Promise<void>
|
|
134
138
|
|
|
135
139
|
// WiFi Commands
|
|
136
140
|
requestWifiScan(): Promise<WifiSearchResult[]>
|
|
@@ -260,7 +264,16 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
260
264
|
* so a caller that depends on the guarantee must gate on platform.
|
|
261
265
|
*/
|
|
262
266
|
setMicSourcePin(source: string | null): Promise<void>
|
|
267
|
+
/** See the public `setWakeWordDetection`. `modelDir` is required when enabling. */
|
|
268
|
+
setWakeWordDetection(enabled: boolean, modelDir?: string | null): Promise<void>
|
|
269
|
+
/** Whether the active recognizer has `path` loaded. Never blocks on a model load. */
|
|
270
|
+
isSttModelLoaded(path: string): Promise<boolean>
|
|
271
|
+
/** See the public `finishTranscription`. */
|
|
272
|
+
finishTranscription(): Promise<string | null>
|
|
273
|
+
/** See the public `restartTranscriber`. */
|
|
263
274
|
restartTranscriber(): Promise<void>
|
|
275
|
+
/** See the public `setSpeechActivityDetection`. */
|
|
276
|
+
setSpeechActivityDetection(enabled: boolean, options?: {minSilenceMs?: number}): Promise<void>
|
|
264
277
|
|
|
265
278
|
// Audio Playback Monitoring
|
|
266
279
|
// Notify native side when our app starts/stops playing audio
|
|
@@ -274,10 +287,15 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
274
287
|
/**
|
|
275
288
|
* Open a PCM stream session. One AudioTrack per id; caller manages ids.
|
|
276
289
|
*
|
|
277
|
-
* `jitterMs`
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
290
|
+
* `jitterMs` (default 500) is how much audio is queued before playback starts, and the playout
|
|
291
|
+
* cushion after that. Omit it for one-way media, where the default cushion is inaudible; pass a
|
|
292
|
+
* small value for conversational audio, where the same cushion is delay before the far end is
|
|
293
|
+
* heard. Both platforms honor it: playback starts once `jitterMs` is queued or the stream is
|
|
294
|
+
* closed, so a sound shorter than `jitterMs` still plays.
|
|
295
|
+
*
|
|
296
|
+
* A stream that has not received audio yet is aborted when the audio route changes (Bluetooth
|
|
297
|
+
* or glasses connect/disconnect, a call starting or ending, an audio-session interruption), so
|
|
298
|
+
* its next write rejects with "stream not open" instead of playing on a stale route.
|
|
281
299
|
*/
|
|
282
300
|
pcmStreamOpen(
|
|
283
301
|
streamId: string,
|
|
@@ -296,6 +314,21 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
296
314
|
pcmStreamClose(streamId: string): Promise<{durationMs: number}>
|
|
297
315
|
/** Stop immediately, dropping any backlog. Idempotent. */
|
|
298
316
|
pcmStreamAbort(streamId: string): Promise<void>
|
|
317
|
+
/**
|
|
318
|
+
* Fetch `url` (HTTP GET) and play its body as raw 16-bit little-endian mono PCM at `sampleRate`
|
|
319
|
+
* while it downloads, through the same stream player as `pcmStreamOpen`. Native code reads the
|
|
320
|
+
* body; audio never crosses into JavaScript. Resolves with the played duration after the whole
|
|
321
|
+
* body has played. Rejects on a non-2xx response or a network error (whatever already played
|
|
322
|
+
* stays played), and with "aborted" after `pcmStreamAbort(streamId)`. Must not block the shared
|
|
323
|
+
* module queue while it runs.
|
|
324
|
+
*/
|
|
325
|
+
pcmStreamPlayUrl(
|
|
326
|
+
streamId: string,
|
|
327
|
+
url: string,
|
|
328
|
+
sampleRate: number,
|
|
329
|
+
volume: number,
|
|
330
|
+
jitterMs?: number,
|
|
331
|
+
): Promise<{durationMs: number}>
|
|
299
332
|
|
|
300
333
|
/** Mentra Live only: K900 `cs_getvol` / `sr_getvol`. */
|
|
301
334
|
getGlassesMediaVolume(): Promise<GlassesMediaVolumeGetResult>
|
|
@@ -756,5 +789,9 @@ NativeBluetoothSdkModule.requestWearTuning = bindNativeMethod<() => Promise<void
|
|
|
756
789
|
)
|
|
757
790
|
NativeBluetoothSdkModule.resetWearTuning = bindNativeMethod<() => Promise<void>>(nativeWearModule, "resetWearTuning")
|
|
758
791
|
|
|
792
|
+
NativeBluetoothSdkModule.sendBesCrashReported = bindNativeMethod<
|
|
793
|
+
(incidentKey: string, reportId: string) => Promise<void>
|
|
794
|
+
>(NativeBluetoothSdkModule as unknown as Record<string, unknown>, "sendBesCrashReported")
|
|
795
|
+
|
|
759
796
|
export default NativeBluetoothSdkModule
|
|
760
797
|
export const BluetoothSdk = NativeBluetoothSdkModule as BluetoothSdkInternalModule
|
|
@@ -54,7 +54,11 @@ type LocalNetworkEvents = {
|
|
|
54
54
|
|
|
55
55
|
declare class MentraLocalNetworkNativeModule extends NativeModule<LocalNetworkEvents> {
|
|
56
56
|
getNetworkDiagnostics(): NetworkDiagnostics
|
|
57
|
-
connect(
|
|
57
|
+
connect(
|
|
58
|
+
ssid: string,
|
|
59
|
+
password: string,
|
|
60
|
+
incoming: boolean,
|
|
61
|
+
): Promise<{connected: boolean; ssid: string; localAddress?: string}>
|
|
58
62
|
request(
|
|
59
63
|
requestId: string,
|
|
60
64
|
url: string,
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/** Generated from /changelogs. Do not edit directly. */
|
|
2
2
|
export const GENERATED_RELEASE_CHANGELOGS = Object.freeze(
|
|
3
3
|
[
|
|
4
|
+
{
|
|
5
|
+
"version": "3.4.1",
|
|
6
|
+
"markdown": "- **Pairing:** Pairing your glasses is simpler, with new voice prompts to guide you. Glasses paired before this update keep working with your current phone.\n- **Mentra Call:** Simpler call controls and a free first month.\n- **Miniapps:** Add miniapps from a link or QR code.\n- **Glasses updates:** Updates keep going when your phone switches networks, with clearer messages if something goes wrong.\n- **Photos and gallery:** More reliable photo syncing on iPhone. Your glasses now tell you when their storage is full.\n- **Livestreaming:** Smoother livestreams.\n- **Sound:** Music no longer stays off after a call.\n- **Notes:** Short conversations now get notes too.\n- **Reliability:** Fewer glasses crashes and disconnects."
|
|
7
|
+
},
|
|
4
8
|
{
|
|
5
9
|
"version": "3.4.0",
|
|
6
|
-
"markdown": "
|
|
10
|
+
"markdown": "- **Pairing:** Pairing your glasses is simpler, with new voice prompts to guide you.\n- **Mentra Call:** Simpler call controls and a free first month.\n- **Miniapps:** Add miniapps from a link or QR code.\n- **Glasses updates:** Updates keep going when your phone switches networks, with clearer messages if something goes wrong.\n- **Photos and gallery:** More reliable photo syncing on iPhone. Your glasses now tell you when their storage is full.\n- **Livestreaming:** Smoother livestreams.\n- **Sound:** Better speaker sound on Mentra Live, and music no longer stays off after a call.\n- **Notes:** Short conversations now get notes too.\n- **Reliability:** Fewer glasses crashes and disconnects."
|
|
7
11
|
},
|
|
8
12
|
{
|
|
9
13
|
"version": "3.3.0",
|
|
10
|
-
"markdown": "
|
|
14
|
+
"markdown": "- **Mentra Call:** Now available on iPhone, with a redesigned call screen and photo sharing during calls.\n- **Microphone:** Improved glasses microphone reliability, including after phone calls.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Glasses updates:** More reliable glasses updates, with clearer progress.\n- **Miniapps:** Miniapps now update automatically. Fixed miniapps getting stuck on loading screens.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Notes:** Take photos with the glasses camera button, and add meeting and location details to your notes.\n- **Pairing and connections:** Improved glasses audio reconnection on Android.\n- **G1 and NIMO:** Improved text display, including accented letters.\n- **Android tablets:** The Mentra App now rotates to landscape."
|
|
11
15
|
},
|
|
12
16
|
{
|
|
13
17
|
"version": "3.2.1",
|
|
@@ -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.4.
|
|
15
|
-
"releaseIdentity": "3.4.
|
|
16
|
-
"releaseSetId": "mentra-3.4.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.
|
|
19
|
-
"otaManifestSha256": "
|
|
14
|
+
"familyBaseVersion": "3.4.1",
|
|
15
|
+
"releaseIdentity": "3.4.1-beta.1409",
|
|
16
|
+
"releaseSetId": "mentra-3.4.1-beta.1409",
|
|
17
|
+
"sourceCommit": "0ac9bbe8869f3e269f43ca87f37382076eca8301",
|
|
18
|
+
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.1/mentra-live-ota-3.4.1-beta.1409.json",
|
|
19
|
+
"otaManifestSha256": "c31a58bc0159c019e95a450eda8d546484210ca4ee39f1220951d2e3b2c5abaf"
|
|
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",
|
|
@@ -63,6 +65,7 @@ const PUBLIC_EVENT_NAMES = new Set<BluetoothSdkEventName>([
|
|
|
63
65
|
"ota_start_ack",
|
|
64
66
|
"ota_status",
|
|
65
67
|
"ar99_ota_status",
|
|
68
|
+
"bes_crash_detected",
|
|
66
69
|
"version_info",
|
|
67
70
|
"extraction_progress",
|
|
68
71
|
])
|
|
@@ -105,7 +108,6 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
105
108
|
PrivateBluetoothSdkModule.onBluetoothStatus(listener),
|
|
106
109
|
getDefaultDevice: bindPublicMethod("getDefaultDevice"),
|
|
107
110
|
setDefaultDevice: bindPublicMethod("setDefaultDevice"),
|
|
108
|
-
clearDefaultDevice: bindPublicMethod("clearDefaultDevice"),
|
|
109
111
|
startScan: bindPublicMethod("startScan"),
|
|
110
112
|
stopScan: bindPublicMethod("stopScan"),
|
|
111
113
|
scan: bindPublicMethod("scan") as BluetoothSdkPublicModule["scan"],
|
|
@@ -114,6 +116,7 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
114
116
|
cancelConnectionAttempt: bindPublicMethod("cancelConnectionAttempt"),
|
|
115
117
|
disconnect: bindPublicMethod("disconnect"),
|
|
116
118
|
forget: bindPublicMethod("forget"),
|
|
119
|
+
unpair: bindPublicMethod("unpair"),
|
|
117
120
|
displayText: bindPublicMethod("displayText"),
|
|
118
121
|
clearDisplay: bindPublicMethod("clearDisplay"),
|
|
119
122
|
setDashboardContent: bindPublicMethod("setDashboardContent"),
|
|
@@ -191,7 +194,10 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
191
194
|
checkSttModelAvailable: bindPublicMethod("checkSttModelAvailable"),
|
|
192
195
|
validateSttModel: bindPublicMethod("validateSttModel"),
|
|
193
196
|
extractTarBz2: bindPublicMethod("extractTarBz2"),
|
|
197
|
+
setWakeWordDetection: bindPublicMethod("setWakeWordDetection"),
|
|
198
|
+
finishTranscription: bindPublicMethod("finishTranscription"),
|
|
194
199
|
restartTranscriber: bindPublicMethod("restartTranscriber"),
|
|
200
|
+
setSpeechActivityDetection: bindPublicMethod("setSpeechActivityDetection"),
|
|
195
201
|
setTtsModelDetails: bindPublicMethod("setTtsModelDetails"),
|
|
196
202
|
getTtsModelPath: bindPublicMethod("getTtsModelPath"),
|
|
197
203
|
getTtsModelLanguage: bindPublicMethod("getTtsModelLanguage"),
|
|
@@ -221,6 +227,10 @@ export type {
|
|
|
221
227
|
AudioDisconnectedEvent,
|
|
222
228
|
AudioPairingNeededEvent,
|
|
223
229
|
BatteryStatusEvent,
|
|
230
|
+
BesCrashDetectedEvent,
|
|
231
|
+
BesCrashEviction,
|
|
232
|
+
BesCrashIncidentState,
|
|
233
|
+
BesCrashSummary,
|
|
224
234
|
BluetoothSdkEvent,
|
|
225
235
|
BluetoothSdkEventListener,
|
|
226
236
|
BluetoothSdkEventMap,
|
|
@@ -253,6 +263,8 @@ export type {
|
|
|
253
263
|
GlassesSessionChangedEvent,
|
|
254
264
|
KeepAliveAckEvent,
|
|
255
265
|
LocalTranscriptionEvent,
|
|
266
|
+
WakeWordEvent,
|
|
267
|
+
SpeechActivityEvent,
|
|
256
268
|
LogEvent,
|
|
257
269
|
MicLc3Event,
|
|
258
270
|
MicHealthEvent,
|
|
@@ -15,8 +15,6 @@ declare class MentraOtaServerModule extends NativeModule<MentraOtaServerModuleEv
|
|
|
15
15
|
host?: string | null,
|
|
16
16
|
): Promise<OtaServerResult>
|
|
17
17
|
stopOtaServer(): Promise<void>
|
|
18
|
-
/** Wait for iPhone Wi-Fi (`en0`) to acquire an address on the glasses gateway subnet. */
|
|
19
|
-
waitForWifiAddress(gateway: string, timeoutMs: number): Promise<string>
|
|
20
18
|
downloadArtifact(source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}>
|
|
21
19
|
}
|
|
22
20
|
|
|
@@ -8,10 +8,6 @@ class MentraOtaServerModule extends NativeModule<MentraOtaServerModuleEvents> {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async stopOtaServer(): Promise<void> {}
|
|
11
|
-
|
|
12
|
-
async waitForWifiAddress(): Promise<string> {
|
|
13
|
-
throw new Error("The OTA server is only available in native apps.")
|
|
14
|
-
}
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
export default registerWebModule(MentraOtaServerModule, "MentraOtaServer")
|
|
@@ -58,15 +58,16 @@ export type OtaServerResult = {
|
|
|
58
58
|
* Scoped networking for traffic that must stay on a Mentra Live hotspot while
|
|
59
59
|
* the phone's default route remains on cellular or another Wi-Fi network.
|
|
60
60
|
*
|
|
61
|
-
* The module is optional because iOS
|
|
61
|
+
* The module is optional because iOS joins through glasses-media's hotspot owner instead.
|
|
62
62
|
*/
|
|
63
63
|
export const otaLocalNetwork = Object.freeze({
|
|
64
64
|
isAvailable: (): boolean => MentraLocalNetwork != null,
|
|
65
65
|
/** Synchronous local observation; no network I/O, route changes or network identities. */
|
|
66
66
|
getNetworkDiagnostics: (): NetworkDiagnostics | null => MentraLocalNetwork?.getNetworkDiagnostics() ?? null,
|
|
67
|
-
connect
|
|
67
|
+
/** `incoming`: the glasses will connect to a server on this phone (OTA), not only the reverse. */
|
|
68
|
+
connect: async (ssid: string, password: string, incoming = true): Promise<OtaLocalNetworkConnection> => {
|
|
68
69
|
if (!MentraLocalNetwork) throw new Error("Scoped local networking is not available in this native build")
|
|
69
|
-
return MentraLocalNetwork.connect(ssid, password)
|
|
70
|
+
return MentraLocalNetwork.connect(ssid, password, incoming)
|
|
70
71
|
},
|
|
71
72
|
request: async (
|
|
72
73
|
requestId: string,
|
|
@@ -116,8 +117,6 @@ export const otaServer = Object.freeze({
|
|
|
116
117
|
host?: string | null,
|
|
117
118
|
): Promise<OtaServerResult> => MentraOtaServer.startOtaServer(manifestJson, artifactPaths, host),
|
|
118
119
|
stop: (): Promise<void> => MentraOtaServer.stopOtaServer(),
|
|
119
|
-
waitForWifiAddress: (gateway: string, timeoutMs: number): Promise<string> =>
|
|
120
|
-
MentraOtaServer.waitForWifiAddress(gateway, timeoutMs),
|
|
121
120
|
downloadArtifact: (source: string, destination: string): Promise<{statusCode: number; bytesWritten: number}> =>
|
|
122
121
|
MentraOtaServer.downloadArtifact(source, destination),
|
|
123
122
|
onArtifactDownloadProgress: (listener: (event: OtaArtifactDownloadProgress) => void): OtaTransportSubscription =>
|
|
@@ -34,7 +34,7 @@ export type UseGlassesConnectionOptions = {
|
|
|
34
34
|
export type GlassesConnectionHookResult = BluetoothStatusHookResult & {
|
|
35
35
|
action: GlassesConnectionAction
|
|
36
36
|
busy: boolean
|
|
37
|
-
|
|
37
|
+
unpair: () => Promise<void>
|
|
38
38
|
connect: (device?: Device, options?: ConnectOptions) => Promise<void>
|
|
39
39
|
connectDefault: (options?: ConnectOptions) => Promise<void>
|
|
40
40
|
defaultDevice: Device | null
|
|
@@ -152,9 +152,9 @@ export function useGlassesConnection(
|
|
|
152
152
|
})
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
async function
|
|
155
|
+
async function unpair() {
|
|
156
156
|
await runConnectionAction("forgetting", async () => {
|
|
157
|
-
await BluetoothSdk.
|
|
157
|
+
await BluetoothSdk.unpair()
|
|
158
158
|
await defaultDeviceStorageRef.current?.save(null)
|
|
159
159
|
setDefaultDeviceState(null)
|
|
160
160
|
scan.selectDevice(null)
|
|
@@ -201,7 +201,7 @@ export function useGlassesConnection(
|
|
|
201
201
|
...status,
|
|
202
202
|
action: scan.scanning ? "scanning" : action,
|
|
203
203
|
busy,
|
|
204
|
-
|
|
204
|
+
unpair,
|
|
205
205
|
connect,
|
|
206
206
|
connectDefault,
|
|
207
207
|
defaultDevice,
|
|
@@ -131,7 +131,7 @@ export type UseMentraBluetoothOptions = {
|
|
|
131
131
|
|
|
132
132
|
export type MentraBluetoothSession = {
|
|
133
133
|
busy: boolean
|
|
134
|
-
|
|
134
|
+
unpair: () => Promise<void>
|
|
135
135
|
connect: (device?: Device, options?: ConnectOptions) => Promise<void>
|
|
136
136
|
connectDefault: (options?: ConnectOptions) => Promise<void>
|
|
137
137
|
defaultDevice: Device | null
|
|
@@ -312,7 +312,7 @@ export function useMentraBluetooth(options: UseMentraBluetoothOptions = {}): Men
|
|
|
312
312
|
|
|
313
313
|
return {
|
|
314
314
|
busy: connection.busy || galleryModeApplying,
|
|
315
|
-
|
|
315
|
+
unpair: connection.unpair,
|
|
316
316
|
connect: connection.connect,
|
|
317
317
|
connectDefault: connection.connectDefault,
|
|
318
318
|
defaultDevice: connection.defaultDevice,
|
|
@@ -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.**
|
|
Binary file
|
|
@@ -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
|
-
}
|