@mentra/bluetooth-sdk 3.3.0-dev.944 → 3.4.0-beta.1237
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 +61 -0
- package/README.md +111 -11
- package/android/build.gradle +60 -51
- package/android/gradle.properties +3 -0
- package/android/settings.gradle +47 -3
- package/android/src/main/java/com/mentra/bluetoothsdk/BesCrashReportWaiters.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkDefaults.kt +5 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +89 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +35 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +159 -110
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +21 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedChangelogCatalog.kt +2 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +6 -6
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +35 -2
- package/android/src/main/java/com/mentra/bluetoothsdk/TouchGesture.kt +19 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/connection/ConnectionModels.kt +5 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/events/BluetoothEvents.kt +16 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicy.kt +64 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +1002 -157
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveOwnerLossPolicy.kt +227 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisement.kt +19 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicy.kt +94 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachine.kt +411 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateStore.kt +124 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Nimo.kt +54 -59
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasCoordinator.kt +5 -32
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasEncoder.kt +8 -1
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/NimoCanvasSession.kt +3 -10
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +6 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/status/DeviceStatus.kt +50 -0
- 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/DeviceManagerOwnerLossTest.kt +146 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusAudioSetupTest.kt +51 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/GlassesStatusClassicAudioTest.kt +2 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/TouchGestureCommandTest.kt +112 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/WifiAdbPeerIntentTest.kt +19 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/GlassesAudioSetupPolicyTest.kt +65 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLiveAudioSetupReadinessTest.kt +231 -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 +368 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingAdvertisementParserTest.kt +20 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingReadinessPolicyTest.kt +136 -0
- package/android/src/test/java/com/mentra/bluetoothsdk/sgcs/MentraLivePairingStateMachineTest.kt +346 -0
- 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/utils/IncidentLogBleRelayNamingTest.kt +23 -0
- 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 +207 -2
- package/build/BluetoothSdk.types.d.ts.map +1 -1
- package/build/BluetoothSdk.types.js.map +1 -1
- package/build/_private/BluetoothSdkModule.d.ts +45 -6
- package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
- package/build/_private/BluetoothSdkModule.js +2 -0
- package/build/_private/BluetoothSdkModule.js.map +1 -1
- package/build/generated/changelogCatalog.d.ts +4 -1
- package/build/generated/changelogCatalog.d.ts.map +1 -1
- package/build/generated/changelogCatalog.js +5 -1
- 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 +10 -0
- package/build/index.js.map +1 -1
- package/ios/BluetoothSdkModule.swift +84 -12
- package/ios/MentraBluetoothSDK.podspec +4 -0
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +23 -5
- package/ios/Resources/SileroVad/silero_vad.onnx +0 -0
- package/ios/Source/BesCrashReportWaiters.swift +64 -0
- package/ios/Source/BluetoothSdkDefaults.swift +2 -2
- package/ios/Source/Bridge.swift +11 -3
- package/ios/Source/DeviceManager.swift +135 -18
- package/ios/Source/DeviceStore.swift +27 -0
- package/ios/Source/GeneratedChangelogCatalog.swift +2 -1
- package/ios/Source/GeneratedReleaseMetadata.swift +6 -6
- package/ios/Source/MentraBluetoothSDK.swift +51 -5
- package/ios/Source/TouchGesture.swift +13 -0
- 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/errors/BluetoothSdkError.swift +5 -1
- package/ios/Source/events/BluetoothEvents.swift +45 -0
- package/ios/Source/internal/BleTraceLogger.swift +9 -6
- package/ios/Source/internal/BluetoothAvailability.swift +15 -5
- package/ios/Source/sgcs/GlassesAudioSetupPolicy.swift +186 -0
- package/ios/Source/sgcs/MentraLive.swift +1366 -212
- package/ios/Source/sgcs/MentraLivePairingAdvertisement.swift +260 -1
- package/ios/Source/sgcs/MentraLivePairingStateMachine.swift +385 -0
- package/ios/Source/sgcs/MentraLivePairingStateStore.swift +121 -0
- package/ios/Source/sgcs/Nimo.swift +10 -3
- package/ios/Source/sgcs/NimoCanvasCoordinator.swift +39 -9
- package/ios/Source/sgcs/SGCManager.swift +13 -0
- package/ios/Source/sgcs/Simulated.swift +2 -0
- package/ios/Source/status/DeviceStatus.swift +35 -0
- 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/types/DeviceModels.swift +8 -1
- package/ios/Source/utils/AudioSessionMonitor.swift +158 -5
- 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/BluetoothAudioRouteTests.swift +82 -0
- package/ios/Tests/DemandDrivenAudioWorkerTests.swift +171 -0
- package/ios/Tests/DeviceManagerReconnectTests.swift +4 -2
- package/ios/Tests/GlassesAudioSetupPolicyTests.swift +197 -0
- package/ios/Tests/IncidentLogDispatchTests.swift +158 -0
- package/ios/Tests/MentraLiveAudioSetupTests.swift +209 -0
- package/ios/Tests/MentraLiveCommandQueueTests.swift +35 -0
- package/ios/Tests/MentraLiveConnectionOptionsTests.swift +55 -0
- package/ios/Tests/MentraLivePairingAdvertisementTests.swift +327 -0
- package/ios/Tests/MentraLivePairingStateMachineTests.swift +402 -0
- package/ios/Tests/MentraLiveSessionReadinessTests.swift +497 -26
- package/ios/Tests/NimoCanvasTransportTests.swift +58 -0
- package/ios/Tests/PcmStreamTests.swift +299 -0
- package/ios/Tests/SpeechActivityTests.swift +238 -0
- package/ios/Tests/SttModelTraitsTests.swift +62 -0
- package/ios/Tests/TouchGestureCommandTests.swift +87 -0
- package/ios/Tests/WifiAdbDispatchTests.swift +118 -0
- package/package.json +3 -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 +216 -1
- package/src/_private/BluetoothSdkModule.ts +49 -5
- package/src/generated/changelogCatalog.ts +5 -1
- package/src/generated/releaseMetadata.ts +6 -6
- package/src/index.ts +24 -0
- 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/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/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 -288
- /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
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
SettingsAckSuccessEvent,
|
|
50
50
|
StreamStartRequest,
|
|
51
51
|
StreamStatusEvent,
|
|
52
|
+
TouchGesture,
|
|
52
53
|
VideoRecordingStartedStatusEvent,
|
|
53
54
|
VideoRecordingSettings,
|
|
54
55
|
VideoRecordingStoppedStatusEvent,
|
|
@@ -96,6 +97,8 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
96
97
|
connectDefaultWithOptions(options: Required<ConnectOptions>): Promise<void>
|
|
97
98
|
setDefaultDevice(device: Device | null): Promise<void>
|
|
98
99
|
clearDefaultDevice(): Promise<void>
|
|
100
|
+
/** Android only: iOS cannot read its Bluetooth bonds. */
|
|
101
|
+
getBondedGlasses?: () => Promise<{name: string; address: string} | null>
|
|
99
102
|
getScanDiagnostic?: (model: DeviceModel) => Promise<ScanDiagnostic | null>
|
|
100
103
|
startScan(model: DeviceModel): Promise<void>
|
|
101
104
|
stopScan(): Promise<void>
|
|
@@ -127,6 +130,12 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
127
130
|
|
|
128
131
|
// Incident Reporting
|
|
129
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>
|
|
130
139
|
|
|
131
140
|
// WiFi Commands
|
|
132
141
|
requestWifiScan(): Promise<WifiSearchResult[]>
|
|
@@ -135,7 +144,7 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
135
144
|
forgetWifiNetwork(ssid: string): Promise<WifiForgetResult>
|
|
136
145
|
setHotspotState(enabled: boolean): Promise<HotspotStatusChangeEvent>
|
|
137
146
|
/** Enable or disable Wi-Fi ADB on Mentra Live (no-op on other devices). */
|
|
138
|
-
setWifiAdbState(enabled: boolean): Promise<void>
|
|
147
|
+
setWifiAdbState(enabled: boolean, expectedBluetoothMac?: string): Promise<void>
|
|
139
148
|
/** Set the glasses system clock when phone detects clock skew (Mentra Live and G2). */
|
|
140
149
|
setSystemTime(timestampMs: number): Promise<void>
|
|
141
150
|
/** Logs current WiFi frequency (MHz) and 5 GHz band to Android logcat. */
|
|
@@ -143,6 +152,7 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
143
152
|
|
|
144
153
|
// Gallery Commands
|
|
145
154
|
setGalleryServerEnabled(enabled: boolean): Promise<SettingsAckSuccessEvent>
|
|
155
|
+
setTouchGestureDefaultBehaviorEnabled(gesture: TouchGesture, enabled: boolean): Promise<SettingsAckSuccessEvent>
|
|
146
156
|
setGalleryModeEnabled(enabled: boolean): Promise<SettingsAckSuccessEvent>
|
|
147
157
|
setVoiceActivityDetectionEnabled(enabled: boolean): Promise<void>
|
|
148
158
|
/** Mentra Live center-mic loudness / Barrier gate (cs_swit type 10). */
|
|
@@ -255,7 +265,16 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
255
265
|
* so a caller that depends on the guarantee must gate on platform.
|
|
256
266
|
*/
|
|
257
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`. */
|
|
258
275
|
restartTranscriber(): Promise<void>
|
|
276
|
+
/** See the public `setSpeechActivityDetection`. */
|
|
277
|
+
setSpeechActivityDetection(enabled: boolean, options?: {minSilenceMs?: number}): Promise<void>
|
|
259
278
|
|
|
260
279
|
// Audio Playback Monitoring
|
|
261
280
|
// Notify native side when our app starts/stops playing audio
|
|
@@ -269,10 +288,15 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
269
288
|
/**
|
|
270
289
|
* Open a PCM stream session. One AudioTrack per id; caller manages ids.
|
|
271
290
|
*
|
|
272
|
-
* `jitterMs`
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
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.
|
|
276
300
|
*/
|
|
277
301
|
pcmStreamOpen(
|
|
278
302
|
streamId: string,
|
|
@@ -291,6 +315,21 @@ declare class BluetoothSdkNativeModule extends NativeModule<BluetoothSdkModuleEv
|
|
|
291
315
|
pcmStreamClose(streamId: string): Promise<{durationMs: number}>
|
|
292
316
|
/** Stop immediately, dropping any backlog. Idempotent. */
|
|
293
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}>
|
|
294
333
|
|
|
295
334
|
/** Mentra Live only: K900 `cs_getvol` / `sr_getvol`. */
|
|
296
335
|
getGlassesMediaVolume(): Promise<GlassesMediaVolumeGetResult>
|
|
@@ -356,6 +395,7 @@ const DEFAULT_CONNECT_OPTIONS: Required<ConnectOptions> = {
|
|
|
356
395
|
saveAsDefault: true,
|
|
357
396
|
cancelExistingConnectionAttempt: true,
|
|
358
397
|
requiresAncs: true,
|
|
398
|
+
enableTransportBridging: true,
|
|
359
399
|
}
|
|
360
400
|
|
|
361
401
|
const DEFAULT_SCAN_TIMEOUT_MS = 15_000
|
|
@@ -750,5 +790,9 @@ NativeBluetoothSdkModule.requestWearTuning = bindNativeMethod<() => Promise<void
|
|
|
750
790
|
)
|
|
751
791
|
NativeBluetoothSdkModule.resetWearTuning = bindNativeMethod<() => Promise<void>>(nativeWearModule, "resetWearTuning")
|
|
752
792
|
|
|
793
|
+
NativeBluetoothSdkModule.sendBesCrashReported = bindNativeMethod<
|
|
794
|
+
(incidentKey: string, reportId: string) => Promise<void>
|
|
795
|
+
>(NativeBluetoothSdkModule as unknown as Record<string, unknown>, "sendBesCrashReported")
|
|
796
|
+
|
|
753
797
|
export default NativeBluetoothSdkModule
|
|
754
798
|
export const BluetoothSdk = NativeBluetoothSdkModule as BluetoothSdkInternalModule
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
export const GENERATED_RELEASE_CHANGELOGS = Object.freeze(
|
|
3
3
|
[
|
|
4
4
|
{
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.4.0",
|
|
6
6
|
"markdown": "This release is under active development. User-facing changes will be documented as they land."
|
|
7
7
|
},
|
|
8
|
+
{
|
|
9
|
+
"version": "3.3.0",
|
|
10
|
+
"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
|
+
},
|
|
8
12
|
{
|
|
9
13
|
"version": "3.2.1",
|
|
10
14
|
"markdown": "- **Livestreamer:** \"Stream Here\" now works without a Wi-Fi network. Improved stream startup and connection reliability.\n- **Photos and gallery:** More reliable photo capture and gallery syncing.\n- **Mentra AI:** Reliability improvements and bug fixes.\n- **Miniapps:** Smoother transitions, with back buttons and gestures that take you to the previous screen inside a miniapp.\n- **Pairing and connections:** Improved G1 pairing and G2 background reconnection.\n- **Glasses updates:** Fixed repeated update checks and improved recovery after interrupted updates.\n- **Mentra Maps:** Bug fixes.\n- **NIMO:** Improved text and map layouts.\n- **Self-hosting:** Connect the Mentra App to your own self-hosted Mentra backend."
|
|
@@ -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.
|
|
15
|
-
"releaseIdentity": "3.
|
|
16
|
-
"releaseSetId": "mentra-3.
|
|
17
|
-
"sourceCommit": "
|
|
18
|
-
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.
|
|
19
|
-
"otaManifestSha256": "
|
|
14
|
+
"familyBaseVersion": "3.4.0",
|
|
15
|
+
"releaseIdentity": "3.4.0-beta.1237",
|
|
16
|
+
"releaseSetId": "mentra-3.4.0-beta.1237",
|
|
17
|
+
"sourceCommit": "ad9203eb7fe636f5a6a77510451d0a8da34b880c",
|
|
18
|
+
"otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.4.0/mentra-live-ota-3.4.0-beta.1237.json",
|
|
19
|
+
"otaManifestSha256": "57f73cac781224161574b4a862c6fb76f98aafd384876ef1b06f998797d5e67f"
|
|
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
|
])
|
|
@@ -128,6 +134,7 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
128
134
|
setSystemTime: bindPublicMethod("setSystemTime"),
|
|
129
135
|
setWifiAdbState: bindPublicMethod("setWifiAdbState"),
|
|
130
136
|
setGalleryServerEnabled: bindPublicMethod("setGalleryServerEnabled"),
|
|
137
|
+
setTouchGestureDefaultBehaviorEnabled: bindPublicMethod("setTouchGestureDefaultBehaviorEnabled"),
|
|
131
138
|
setGalleryModeEnabled: bindPublicMethod("setGalleryModeEnabled"),
|
|
132
139
|
setVoiceActivityDetectionEnabled: bindPublicMethod("setVoiceActivityDetectionEnabled"),
|
|
133
140
|
setLoudnessGateEnabled: bindPublicMethod("setLoudnessGateEnabled"),
|
|
@@ -187,7 +194,10 @@ export const BluetoothSdk: BluetoothSdkPublicModule = Object.freeze({
|
|
|
187
194
|
checkSttModelAvailable: bindPublicMethod("checkSttModelAvailable"),
|
|
188
195
|
validateSttModel: bindPublicMethod("validateSttModel"),
|
|
189
196
|
extractTarBz2: bindPublicMethod("extractTarBz2"),
|
|
197
|
+
setWakeWordDetection: bindPublicMethod("setWakeWordDetection"),
|
|
198
|
+
finishTranscription: bindPublicMethod("finishTranscription"),
|
|
190
199
|
restartTranscriber: bindPublicMethod("restartTranscriber"),
|
|
200
|
+
setSpeechActivityDetection: bindPublicMethod("setSpeechActivityDetection"),
|
|
191
201
|
setTtsModelDetails: bindPublicMethod("setTtsModelDetails"),
|
|
192
202
|
getTtsModelPath: bindPublicMethod("getTtsModelPath"),
|
|
193
203
|
getTtsModelLanguage: bindPublicMethod("getTtsModelLanguage"),
|
|
@@ -217,6 +227,10 @@ export type {
|
|
|
217
227
|
AudioDisconnectedEvent,
|
|
218
228
|
AudioPairingNeededEvent,
|
|
219
229
|
BatteryStatusEvent,
|
|
230
|
+
BesCrashDetectedEvent,
|
|
231
|
+
BesCrashEviction,
|
|
232
|
+
BesCrashIncidentState,
|
|
233
|
+
BesCrashSummary,
|
|
220
234
|
BluetoothSdkEvent,
|
|
221
235
|
BluetoothSdkEventListener,
|
|
222
236
|
BluetoothSdkEventMap,
|
|
@@ -249,6 +263,8 @@ export type {
|
|
|
249
263
|
GlassesSessionChangedEvent,
|
|
250
264
|
KeepAliveAckEvent,
|
|
251
265
|
LocalTranscriptionEvent,
|
|
266
|
+
WakeWordEvent,
|
|
267
|
+
SpeechActivityEvent,
|
|
252
268
|
LogEvent,
|
|
253
269
|
MicLc3Event,
|
|
254
270
|
MicHealthEvent,
|
|
@@ -265,9 +281,16 @@ export type {
|
|
|
265
281
|
OtaUpdateInfo,
|
|
266
282
|
ReleaseChangelog,
|
|
267
283
|
MtkUpdateCompleteEvent,
|
|
284
|
+
PairFailureCode,
|
|
268
285
|
PairFailureEvent,
|
|
269
286
|
PairingInfoEvent,
|
|
270
287
|
EnteringPairingModeEvent,
|
|
288
|
+
MentraLivePairingState,
|
|
289
|
+
PairingModeEndedEvent,
|
|
290
|
+
PairingModeEndedReason,
|
|
291
|
+
PairingStateChangedEvent,
|
|
292
|
+
GlassesAudioSetupState,
|
|
293
|
+
AudioSetupChangedEvent,
|
|
271
294
|
OwnerReplacedEvent,
|
|
272
295
|
PhotoCaptureMetadata,
|
|
273
296
|
PhotoResolvedConfig,
|
|
@@ -311,6 +334,7 @@ export type {
|
|
|
311
334
|
SwipeVolumeStatusEvent,
|
|
312
335
|
SwitchStatusEvent,
|
|
313
336
|
TouchEvent,
|
|
337
|
+
TouchGesture,
|
|
314
338
|
VideoRecordingDefaults,
|
|
315
339
|
VideoRecordingStartedStatusEvent,
|
|
316
340
|
VideoRecordingStatusEvent,
|
|
@@ -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
|
-
}
|