@mentra/bluetooth-sdk 3.4.0-dev.998 → 3.5.0-dev.1238

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 (140) hide show
  1. package/README.md +33 -11
  2. package/android/build.gradle +60 -51
  3. package/android/gradle.properties +3 -0
  4. package/android/settings.gradle +47 -3
  5. package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
  6. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -2
  7. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +76 -3
  8. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +27 -0
  9. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +98 -120
  10. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -1
  11. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
  12. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +24 -9
  13. package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
  14. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +170 -23
  15. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +13 -316
  16. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +0 -35
  17. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +2 -10
  18. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
  19. package/android/src/main/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueue.kt +92 -0
  20. package/android/src/main/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHost.kt +169 -0
  21. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +74 -115
  22. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +348 -357
  23. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetector.kt +211 -0
  24. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngine.kt +137 -0
  25. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SttTextFormatter.kt +52 -0
  26. package/android/src/main/java/com/mentra/bluetoothsdk/stt/WakeWordDetector.kt +235 -0
  27. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AvifExifStripper.java +2 -2
  28. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +3 -3
  29. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +11 -0
  30. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/AudioRouteWatcher.kt +120 -0
  31. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +181 -16
  32. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlayback.kt +177 -0
  33. package/android/src/test/java/com/mentra/bluetoothsdk/BesCrashReportWaitersTest.kt +112 -0
  34. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveGlassesReadyBurstTest.kt +141 -0
  35. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveIncidentDispatchTest.kt +183 -0
  36. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveRgbLedResponseTest.kt +76 -0
  37. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinatorTest.kt +1 -56
  38. package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSessionTest.kt +0 -22
  39. package/android/src/test/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNamingTest.kt +23 -0
  40. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/BoundedAudioQueueTest.kt +81 -0
  41. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/OnDeviceRecognizerHostTest.kt +216 -0
  42. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/STTToolsExtractionTest.kt +108 -0
  43. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityDetectorTest.kt +126 -0
  44. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SpeechActivityEngineTest.kt +245 -0
  45. package/android/src/testDebug/java/com/mentra/bluetoothsdk/stt/SttTextFormatterTest.kt +67 -0
  46. package/android/src/testDebug/java/com/mentra/bluetoothsdk/utils/audio/PcmUrlPlaybackTest.kt +76 -0
  47. package/build/BluetoothSdk.types.d.ts +98 -1
  48. package/build/BluetoothSdk.types.d.ts.map +1 -1
  49. package/build/BluetoothSdk.types.js.map +1 -1
  50. package/build/_private/BluetoothSdkModule.d.ts +42 -7
  51. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  52. package/build/_private/BluetoothSdkModule.js +1 -0
  53. package/build/_private/BluetoothSdkModule.js.map +1 -1
  54. package/build/generated/changelogCatalog.d.ts +4 -1
  55. package/build/generated/changelogCatalog.d.ts.map +1 -1
  56. package/build/generated/changelogCatalog.js +5 -1
  57. package/build/generated/changelogCatalog.js.map +1 -1
  58. package/build/generated/releaseMetadata.js +6 -6
  59. package/build/generated/releaseMetadata.js.map +1 -1
  60. package/build/index.d.ts +1 -1
  61. package/build/index.d.ts.map +1 -1
  62. package/build/index.js +6 -0
  63. package/build/index.js.map +1 -1
  64. package/ios/BluetoothSdkModule.swift +66 -14
  65. package/ios/MentraBluetoothSDK.podspec +4 -0
  66. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
  67. package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
  68. package/ios/Source/BesCrashReportWaiters.swift +64 -0
  69. package/ios/Source/BluetoothSdkDefaults.swift +2 -2
  70. package/ios/Source/DeviceManager.swift +43 -22
  71. package/ios/Source/GeneratedChangelogCatalog.swift +2 -1
  72. package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
  73. package/ios/Source/MentraBluetoothSDK.swift +27 -15
  74. package/ios/Source/audio/PcmStreamPlayer.swift +290 -57
  75. package/ios/Source/audio/PcmUrlPlayback.swift +231 -0
  76. package/ios/Source/audio/SpeechActivity.swift +277 -0
  77. package/ios/Source/events/BluetoothEvents.swift +41 -0
  78. package/ios/Source/internal/BluetoothAvailability.swift +15 -5
  79. package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +5 -0
  80. package/ios/Source/sgcs/MentraLive.swift +173 -42
  81. package/ios/Source/sgcs/Nimo.swift +39 -272
  82. package/ios/Source/sgcs/NimoCanvasCoordinator.swift +9 -38
  83. package/ios/Source/sgcs/NimoCanvasSession.swift +0 -1
  84. package/ios/Source/sgcs/SGCManager.swift +6 -0
  85. package/ios/Source/stt/STTTools.swift +13 -31
  86. package/ios/Source/stt/SherpaOnnxTranscriber.swift +204 -162
  87. package/ios/Source/stt/SileroSpeechActivity.swift +87 -0
  88. package/ios/Source/stt/WakeWordDetector.swift +145 -0
  89. package/ios/Source/utils/BoundedWait.swift +44 -0
  90. package/ios/Source/utils/DemandDrivenAudioWorker.swift +79 -0
  91. package/ios/Source/utils/SttModelTraits.swift +62 -0
  92. package/ios/Tests/BesCrashReportTests.swift +142 -0
  93. package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
  94. package/ios/Tests/DeviceManagerReconnectTests.swift +0 -71
  95. package/ios/Tests/GlassesAudioSetupPolicyTests.swift +9 -3
  96. package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
  97. package/ios/Tests/MentraLiveAudioSetupTests.swift +6 -12
  98. package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
  99. package/ios/Tests/MentraLiveSessionReadinessTests.swift +179 -10
  100. package/ios/Tests/NimoCanvasTransportTests.swift +0 -89
  101. package/ios/Tests/PcmStreamTests.swift +299 -0
  102. package/ios/Tests/SpeechActivityTests.swift +238 -0
  103. package/ios/Tests/SttModelTraitsTests.swift +62 -0
  104. package/package.json +2 -2
  105. package/plugin/build/withAndroid.js +9 -11
  106. package/plugin/build/withKotlinVersion.d.ts +2 -0
  107. package/plugin/build/withKotlinVersion.js +46 -0
  108. package/src/BluetoothSdk.types.ts +102 -1
  109. package/src/_private/BluetoothSdkModule.ts +45 -7
  110. package/src/generated/changelogCatalog.ts +5 -1
  111. package/src/generated/releaseMetadata.ts +6 -6
  112. package/src/index.ts +12 -0
  113. package/android/silero/LICENSE.md +0 -17
  114. package/android/silero/build.gradle +0 -50
  115. package/android/silero/proguard-rules.pro +0 -24
  116. package/android/silero/src/androidTest/assets/hello.wav +0 -0
  117. package/android/silero/src/androidTest/java/com/konovalov/vad/silero/VadSileroTest.kt +0 -79
  118. package/android/silero/src/main/java/com/konovalov/vad/silero/Vad.kt +0 -160
  119. package/android/silero/src/main/java/com/konovalov/vad/silero/VadSilero.kt +0 -449
  120. package/android/silero/src/main/java/com/konovalov/vad/silero/config/FrameSize.kt +0 -15
  121. package/android/silero/src/main/java/com/konovalov/vad/silero/config/Mode.kt +0 -14
  122. package/android/silero/src/main/java/com/konovalov/vad/silero/config/SampleRate.kt +0 -12
  123. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/AudioUtils.kt +0 -47
  124. package/android/silero/src/main/java/com/konovalov/vad/silero/utils/TensorMap.kt +0 -41
  125. package/android/silero/src/test/java/com/konovalov/vad/silero/utils/AudioUtilsTest.kt +0 -44
  126. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -368
  127. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocol.kt +0 -156
  128. package/android/src/debug/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -274
  129. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +0 -229
  130. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnostics.kt +0 -20
  131. package/android/src/release/java/com/mentra/bluetoothsdk/sgcs/NimoResourceDiagnostics.kt +0 -16
  132. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoDiagnosticsTest.kt +0 -287
  133. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoFramebufferProtocolTest.kt +0 -127
  134. package/android/src/testDebug/java/com/mentra/bluetoothsdk/sgcs/NimoLifecycleTest.kt +0 -851
  135. package/ios/Source/sgcs/NimoMacResourceTransport.swift +0 -217
  136. package/ios/Source/sgcs/NimoResourceFixture.swift +0 -384
  137. package/ios/Source/sgcs/NimoResourceSession.swift +0 -406
  138. package/ios/Tests/NimoResourceSessionTests.swift +0 -476
  139. /package/android/{silero/src/main/assets/LICENSE → src/main/assets/vad/LICENSE.silero_vad} +0 -0
  140. /package/android/{silero/src/main/assets → src/main/assets/vad}/silero_vad.onnx +0 -0
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withKotlinVersion = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ // avif-coder 3.0.0 contains Kotlin 2.3 metadata. Match the standalone SDK
6
+ // compiler and @mentra/crust; Expo SDK 55 also has a KSP mapping for 2.3.0.
7
+ const MIN_KOTLIN_VERSION = "2.3.0";
8
+ const UNVERSIONED_KOTLIN_PLUGIN = "classpath('org.jetbrains.kotlin:kotlin-gradle-plugin')";
9
+ const PINNED_KOTLIN_PLUGIN = `classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:\${findProperty('android.kotlinVersion')}")`;
10
+ const ROOT_KOTLIN_VERSION = "ext.kotlinVersion = findProperty('android.kotlinVersion')";
11
+ const EXPO_ROOT_PROJECT = 'apply plugin: "expo-root-project"';
12
+ function isOlderVersion(version) {
13
+ const actual = version.split(".").map(Number);
14
+ const minimum = MIN_KOTLIN_VERSION.split(".").map(Number);
15
+ for (let index = 0; index < minimum.length; index++) {
16
+ if ((actual[index] ?? 0) !== minimum[index])
17
+ return (actual[index] ?? 0) < minimum[index];
18
+ }
19
+ return false;
20
+ }
21
+ const withKotlinVersion = (config) => {
22
+ config = (0, config_plugins_1.withGradleProperties)(config, (cfg) => {
23
+ const property = cfg.modResults.find((item) => item.type === "property" && item.key === "android.kotlinVersion");
24
+ if (property?.type !== "property") {
25
+ cfg.modResults.push({ type: "property", key: "android.kotlinVersion", value: MIN_KOTLIN_VERSION });
26
+ }
27
+ else if (isOlderVersion(property.value)) {
28
+ property.value = MIN_KOTLIN_VERSION;
29
+ }
30
+ return cfg;
31
+ });
32
+ return (0, config_plugins_1.withProjectBuildGradle)(config, (cfg) => {
33
+ if (cfg.modResults.language !== "groovy")
34
+ return cfg;
35
+ // Expo 55's unversioned classpath resolves React Native's Kotlin 2.1.20
36
+ // compiler even when android.kotlinVersion is set. Pin the actual plugin
37
+ // and Expo's version catalog, as @mentra/crust does for QuickJS.
38
+ let gradle = cfg.modResults.contents.replace(UNVERSIONED_KOTLIN_PLUGIN, PINNED_KOTLIN_PLUGIN);
39
+ if (!gradle.includes(ROOT_KOTLIN_VERSION)) {
40
+ gradle = gradle.replace(EXPO_ROOT_PROJECT, `// Kotlin compiler required by @mentra/bluetooth-sdk's AVIF decoder.\n${ROOT_KOTLIN_VERSION}\n${EXPO_ROOT_PROJECT}`);
41
+ }
42
+ cfg.modResults.contents = gradle;
43
+ return cfg;
44
+ });
45
+ };
46
+ exports.withKotlinVersion = withKotlinVersion;
@@ -100,6 +100,28 @@ export type GlassesMediaVolumeSetResult = {
100
100
  statusCode: number
101
101
  }
102
102
 
103
+ /** On-device keyword spotter state and detections. Describes only the wake-word model. */
104
+ export type WakeWordEvent = {
105
+ kind: "loading" | "ready" | "detected" | "error"
106
+ phrase: string
107
+ /** Unix epoch milliseconds. */
108
+ timestamp: number
109
+ message?: string
110
+ }
111
+
112
+ /**
113
+ * Phone-side speech activity from the on-device Silero detector
114
+ * ([setSpeechActivityDetection]). Sent on transitions only. A gap in incoming
115
+ * microphone audio counts as silence.
116
+ */
117
+ export type SpeechActivityEvent = {
118
+ speaking: boolean
119
+ /** 0 while speaking; on a silence transition, how long the audio has been silent. */
120
+ silentForMs: number
121
+ /** Unix epoch milliseconds. */
122
+ timestamp: number
123
+ }
124
+
103
125
  export type LocalTranscriptionEvent = {
104
126
  text: string
105
127
  isFinal?: boolean
@@ -916,7 +938,8 @@ export type PairingStateChangedEvent = {
916
938
  * - `not_applicable`: no user step for audio. Android attaches Classic audio from the BLE bond,
917
939
  * and glasses without Classic audio have nothing to set up.
918
940
  * - `connecting`: the glasses are connected, audio is not, and the SDK still expects audio to
919
- * come up on its own (for example iPhone audio derived from the BLE pair).
941
+ * come up on its own (for example iPhone audio derived from the BLE pair). After setup, Mentra
942
+ * Live firmware that reports `classic_link` reconnects audio itself and stays here.
920
943
  * - `connected`: Classic audio (A2DP or HFP) to the glasses is up.
921
944
  * - `needs_user`: audio did not come up on its own. Ask the user to connect the glasses in the
922
945
  * system Bluetooth settings (iPhone: Settings > Bluetooth). The state moves to `connected`
@@ -1192,6 +1215,54 @@ export type OtaStatusEvent = {
1192
1215
 
1193
1216
  export type OtaQueryResult = OtaStatusEvent
1194
1217
 
1218
+ /** Lifecycle of a BES crash incident bundle on Mentra Live glasses. */
1219
+ export type BesCrashIncidentState = "COLLECTING" | "STORED" | "REPORTED" | "UPLOADED" | "EVICTED"
1220
+
1221
+ /** One incident bundle the glasses dropped to stay within their storage budget. */
1222
+ export type BesCrashEviction = {
1223
+ incidentKey: string
1224
+ reason: string
1225
+ bytes: number
1226
+ ms: number
1227
+ }
1228
+
1229
+ /**
1230
+ * Glasses-side summary of a BES crash incident. Fields the glasses could not
1231
+ * determine (for example `dumpId` of a reset without a dump) may be absent or null.
1232
+ */
1233
+ export type BesCrashSummary = {
1234
+ attribution: "match" | "older" | "unknown"
1235
+ dumpId?: string | null
1236
+ bootId?: string | null
1237
+ resetHw?: number | null
1238
+ resetSw?: number | null
1239
+ crashUnixMs?: number | null
1240
+ coveredFromMs?: number | null
1241
+ coveredToMs?: number | null
1242
+ traceGaps: number
1243
+ truncated: boolean
1244
+ torn: boolean
1245
+ tailCaptured: boolean
1246
+ dumpGap: boolean
1247
+ evictedCount: number
1248
+ recentEvictions: BesCrashEviction[]
1249
+ }
1250
+
1251
+ /**
1252
+ * Mentra Live stored a BES crash or unexpected-reset incident. Sent when the
1253
+ * incident becomes `STORED`, and again on every reconnect while it is `STORED`
1254
+ * or `REPORTED`, so handlers must be idempotent per `incidentKey`.
1255
+ */
1256
+ export type BesCrashDetectedEvent = {
1257
+ type: "bes_crash_detected"
1258
+ incidentKey: string
1259
+ reason: "bes_crash" | "bes_unexpected_reset"
1260
+ state: BesCrashIncidentState
1261
+ /** Cloud report already recorded for this incident, or null before one is reported. */
1262
+ reportId: string | null
1263
+ summary: BesCrashSummary
1264
+ }
1265
+
1195
1266
  /** Nex BLE protobuf trace (NexEventUtils); payload matches native Map keys. */
1196
1267
  export type BleCommandTraceEvent = {
1197
1268
  command: string
@@ -1223,6 +1294,8 @@ export type BluetoothSdkModuleEvents = {
1223
1294
  voice_activity_detection_status: (event: VoiceActivityDetectionStatusEvent) => void
1224
1295
  speaking_status: (event: SpeakingStatusEvent) => void
1225
1296
  battery_status: (event: BatteryStatusEvent) => void
1297
+ wake_word: (event: WakeWordEvent) => void
1298
+ speech_activity: (event: SpeechActivityEvent) => void
1226
1299
  local_transcription: (event: LocalTranscriptionEvent) => void
1227
1300
  native_notification_status: (event: NativeNotificationStatus) => void
1228
1301
  native_notification_delivery: (event: NativeNotificationDelivery) => void
@@ -1276,6 +1349,7 @@ export type BluetoothSdkModuleEvents = {
1276
1349
  ota_start_ack: (event: OtaStartAckEvent) => void
1277
1350
  ota_status: (event: OtaStatusEvent) => void
1278
1351
  ar99_ota_status: (event: Ar99OtaStatusEvent) => void
1352
+ bes_crash_detected: (event: BesCrashDetectedEvent) => void
1279
1353
  version_info: (event: VersionInfoEvent) => void
1280
1354
  send_command_to_ble: (event: BleCommandTraceEvent) => void
1281
1355
  receive_command_from_ble: (event: BleCommandTraceEvent) => void
@@ -1397,6 +1471,8 @@ export type BluetoothSdkEventMap = {
1397
1471
  voice_activity_detection_status: VoiceActivityDetectionStatusEvent
1398
1472
  speaking_status: SpeakingStatusEvent
1399
1473
  battery_status: BatteryStatusEvent
1474
+ wake_word: WakeWordEvent
1475
+ speech_activity: SpeechActivityEvent
1400
1476
  local_transcription: LocalTranscriptionEvent
1401
1477
  wifi_status_change: WifiStatusChangeEvent
1402
1478
  wifi_scan_result: WifiScanResultEvent
@@ -1442,6 +1518,8 @@ export type BluetoothSdkEventMap = {
1442
1518
  ota_start_ack: OtaStartAckEvent
1443
1519
  ota_status: OtaStatusEvent
1444
1520
  ar99_ota_status: Ar99OtaStatusEvent
1521
+ /** Mentra Live stored a BES crash incident for the phone to report. */
1522
+ bes_crash_detected: BesCrashDetectedEvent
1445
1523
  version_info: VersionInfoEvent
1446
1524
  extraction_progress: ExtractionProgressEvent
1447
1525
  }
@@ -1647,7 +1725,30 @@ export interface BluetoothSdkPublicModule {
1647
1725
  checkSttModelAvailable(): Promise<boolean>
1648
1726
  validateSttModel(path: string): Promise<boolean>
1649
1727
  extractTarBz2(sourcePath: string, destinationPath: string): Promise<boolean>
1728
+ /**
1729
+ * Start or stop on-device keyword spotting on microphone PCM. `modelDir` must contain
1730
+ * `encoder.int8.onnx`, `decoder.onnx`, `joiner.int8.onnx`, `tokens.txt` and `keywords.txt`;
1731
+ * it is required when enabling. Disabling releases the model.
1732
+ */
1733
+ setWakeWordDetection(enabled: boolean, modelDir?: string | null): Promise<void>
1734
+ /**
1735
+ * Finalize the active on-device recognizer's current utterance now. Resolves after the final
1736
+ * `local_transcription` event for it has been emitted, with that final text (empty when nothing
1737
+ * was pending). Resolves `null` when no streaming model is active or the loaded model can't
1738
+ * finalize early.
1739
+ */
1740
+ finishTranscription(): Promise<string | null>
1741
+ /**
1742
+ * Reload the selected speech model when on-device transcription is in demand. Resolves after
1743
+ * it is loaded; rejects when loading fails; resolves immediately when there is no demand.
1744
+ */
1650
1745
  restartTranscriber(): Promise<void>
1746
+ /**
1747
+ * Start or stop the on-device Silero speech detector on microphone PCM. While enabled it emits
1748
+ * `speech_activity` transitions; `minSilenceMs` (default 300) is the quiet gap before a silence
1749
+ * transition. Disabling releases the model.
1750
+ */
1751
+ setSpeechActivityDetection(enabled: boolean, options?: {minSilenceMs?: number}): Promise<void>
1651
1752
 
1652
1753
  // TTS Commands (TODO: MOVE TO CRUST)
1653
1754
  setTtsModelDetails(path: string, languageCode: string): Promise<void>
@@ -93,13 +93,12 @@ 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
  clearDefaultDevice(): Promise<void>
100
+ /** Android only: iOS cannot read its Bluetooth bonds. */
101
+ getBondedGlasses?: () => Promise<{name: string; address: string} | null>
103
102
  getScanDiagnostic?: (model: DeviceModel) => Promise<ScanDiagnostic | null>
104
103
  startScan(model: DeviceModel): Promise<void>
105
104
  stopScan(): Promise<void>
@@ -131,6 +130,12 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
131
130
 
132
131
  // Incident Reporting
133
132
  sendIncidentId(incidentId: string, apiBaseUrl?: string | null): Promise<void>
133
+ /**
134
+ * Tell Mentra Live that Cloud recorded `reportId` for the BES crash incident
135
+ * `incidentKey`. Resolves only on the glasses' matching `ok:true` ack; rejects
136
+ * on `ok:false`, disconnect, or after 10 s. Call `sendIncidentId` only after it resolves.
137
+ */
138
+ sendBesCrashReported(incidentKey: string, reportId: string): Promise<void>
134
139
 
135
140
  // WiFi Commands
136
141
  requestWifiScan(): Promise<WifiSearchResult[]>
@@ -260,7 +265,16 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
260
265
  * so a caller that depends on the guarantee must gate on platform.
261
266
  */
262
267
  setMicSourcePin(source: string | null): Promise<void>
268
+ /** See the public `setWakeWordDetection`. `modelDir` is required when enabling. */
269
+ setWakeWordDetection(enabled: boolean, modelDir?: string | null): Promise<void>
270
+ /** Whether the active recognizer has `path` loaded. Never blocks on a model load. */
271
+ isSttModelLoaded(path: string): Promise<boolean>
272
+ /** See the public `finishTranscription`. */
273
+ finishTranscription(): Promise<string | null>
274
+ /** See the public `restartTranscriber`. */
263
275
  restartTranscriber(): Promise<void>
276
+ /** See the public `setSpeechActivityDetection`. */
277
+ setSpeechActivityDetection(enabled: boolean, options?: {minSilenceMs?: number}): Promise<void>
264
278
 
265
279
  // Audio Playback Monitoring
266
280
  // Notify native side when our app starts/stops playing audio
@@ -274,10 +288,15 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
274
288
  /**
275
289
  * Open a PCM stream session. One AudioTrack per id; caller manages ids.
276
290
  *
277
- * `jitterMs` sizes the playout buffer and is therefore also the stream's floor latency, since a
278
- * streaming track fills to its buffer and stays there. Omit it for one-way media, where the
279
- * default cushion is inaudible; pass a small value for conversational audio, where the same
280
- * cushion is delay before the far end is heard. Android only — iOS accepts and ignores it.
291
+ * `jitterMs` (default 500) is how much audio is queued before playback starts, and the playout
292
+ * cushion after that. Omit it for one-way media, where the default cushion is inaudible; pass a
293
+ * small value for conversational audio, where the same cushion is delay before the far end is
294
+ * heard. Both platforms honor it: playback starts once `jitterMs` is queued or the stream is
295
+ * closed, so a sound shorter than `jitterMs` still plays.
296
+ *
297
+ * A stream that has not received audio yet is aborted when the audio route changes (Bluetooth
298
+ * or glasses connect/disconnect, a call starting or ending, an audio-session interruption), so
299
+ * its next write rejects with "stream not open" instead of playing on a stale route.
281
300
  */
282
301
  pcmStreamOpen(
283
302
  streamId: string,
@@ -296,6 +315,21 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
296
315
  pcmStreamClose(streamId: string): Promise<{durationMs: number}>
297
316
  /** Stop immediately, dropping any backlog. Idempotent. */
298
317
  pcmStreamAbort(streamId: string): Promise<void>
318
+ /**
319
+ * Fetch `url` (HTTP GET) and play its body as raw 16-bit little-endian mono PCM at `sampleRate`
320
+ * while it downloads, through the same stream player as `pcmStreamOpen`. Native code reads the
321
+ * body; audio never crosses into JavaScript. Resolves with the played duration after the whole
322
+ * body has played. Rejects on a non-2xx response or a network error (whatever already played
323
+ * stays played), and with "aborted" after `pcmStreamAbort(streamId)`. Must not block the shared
324
+ * module queue while it runs.
325
+ */
326
+ pcmStreamPlayUrl(
327
+ streamId: string,
328
+ url: string,
329
+ sampleRate: number,
330
+ volume: number,
331
+ jitterMs?: number,
332
+ ): Promise<{durationMs: number}>
299
333
 
300
334
  /** Mentra Live only: K900 `cs_getvol` / `sr_getvol`. */
301
335
  getGlassesMediaVolume(): Promise<GlassesMediaVolumeGetResult>
@@ -756,5 +790,9 @@ NativeBluetoothSdkModule.requestWearTuning = bindNativeMethod<() => Promise<void
756
790
  )
757
791
  NativeBluetoothSdkModule.resetWearTuning = bindNativeMethod<() => Promise<void>>(nativeWearModule, "resetWearTuning")
758
792
 
793
+ NativeBluetoothSdkModule.sendBesCrashReported = bindNativeMethod<
794
+ (incidentKey: string, reportId: string) => Promise<void>
795
+ >(NativeBluetoothSdkModule as unknown as Record<string, unknown>, "sendBesCrashReported")
796
+
759
797
  export default NativeBluetoothSdkModule
760
798
  export const BluetoothSdk = NativeBluetoothSdkModule as BluetoothSdkInternalModule
@@ -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.5.0",
6
+ "markdown": "This release is under active development. User-facing changes will be documented as they land."
7
+ },
4
8
  {
5
9
  "version": "3.4.0",
6
10
  "markdown": "This release is under active development. User-facing changes will be documented as they land."
7
11
  },
8
12
  {
9
13
  "version": "3.3.0",
10
- "markdown": "This release is under active development. User-facing changes will be documented as they land."
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.0",
15
- "releaseIdentity": "3.4.0-dev.998",
16
- "releaseSetId": "mentra-3.4.0-dev.998",
17
- "sourceCommit": "c77108af50fcaabe3f2c1464b2a5d649a30e337b",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-dev.998.json",
19
- "otaManifestSha256": "8c797478019499beb9a637bf418ff6586fd974115f712dfb51c7a96f6e08151c"
14
+ "familyBaseVersion": "3.5.0",
15
+ "releaseIdentity": "3.5.0-dev.1238",
16
+ "releaseSetId": "mentra-3.5.0-dev.1238",
17
+ "sourceCommit": "e8aa2cac40175a5b7b1dfd1611283d81bbc7fa6a",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.5.0/mentra-live-ota-3.5.0-dev.1238.json",
19
+ "otaManifestSha256": "acc6bbbd9195865992bfc8d1b6f16c7b9cb2f8087849b37c84173d834976c4be"
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
  ])
@@ -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,
@@ -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
- }