Mentra Miniapp SDK betaThe SDK is in beta, so its APIs may change before general availability.To put a miniapp in front of users, host it at an HTTPS URL and share the link, or get it listed in the Mentra Miniapp Store. See Publish your miniapp.Developing on Mentra Live? We recommend using the Mentra Bluetooth SDK.The developer tools are available in the Mentra App under Settings → Miniapp Developer Settings.Share feedback with an in-app bug report, on Discord, or by email at [email protected].
session.transcription turns what the user says into text. Register a handler and you start getting results; the SDK handles the subscription for you.
Transcription needs the MICROPHONE permission in your manifest. Without it, the phone rejects the subscription with PERMISSION_NOT_DECLARED and no events arrive.

Results

Each event is a TranscriptionData: Interim results stream as the user speaks and get replaced; wait for isFinal if you only want settled text.

Targeting languages

on() auto-detects the language. To listen for specific ones, use forLanguage() with BCP-47 tags:
Each call is independent, and you can have several active at the same time.

Cloud or on-device

Each listener chooses where its speech is transcribed with the processing option, the final argument of on() and forLanguage():
preferLocal is the choice for a miniapp that listens all day: it keeps the quality of the cloud as a fallback and costs nothing while the phone can do the work. When no listener on a stream needs the cloud, the phone doesn’t send that audio to the cloud at all. The phone runs one on-device speech model at a time, the one the user picked on its Speech page, and every miniapp’s on-device transcription uses it. If it isn’t downloaded yet, the phone downloads it when a preferLocal or localOnly listener in its language arrives, and loads it while any of them stays subscribed.
  • forLanguage() gets on-device text only when the model is in that language. A preferLocal listener in another language stays on the cloud; a localOnly one gets no text.
  • on() (auto-detect) follows the model’s language, so it gets on-device text in whatever language the user picked. A preferLocal listener whose miniapp set configure({languageHints}) to a language the model can’t transcribe stays on the cloud, which can tell those languages apart.
A listener moves between the cloud and on-device by itself: when the model finishes downloading or loading, when it fails, when the user picks another model, or when the cloud connection drops or returns. It moves during a pause in speech, once both the cloud and the phone have finished with what was said before it, so it never misses speech or hears the same speech twice. In continuous speech the move waits for the next pause of a few seconds. If its current source stops working, it moves right away. Check data.source to see where each result came from. Routing is per listener. Other listeners on the same stream, and other miniapps, keep their own choice.
processing replaces {forceLocal: true}, which still works as processing: "localOnly" until SDK 4.0. When both are set, processing wins. Mentra App versions before 3.4.0 don’t know processing: there, "preferLocal" behaves like "preferCloud", and "localOnly" keeps working.

Model status

onModelStatus tells you what the on-device model behind your subscriptions is doing. You get the current state right away, then every change:
Your on-device listeners are the preferLocal and localOnly ones, and every listener while the cloud is unreachable. The state is unavailable when you have none, when the download or load failed (the phone retries on its own), or when every one of them asks for a language other than the picked model’s (reason names the picked language).

Ending an utterance early

A recognizer ends a line after its own end-of-speech pause. When your own rule decides the user is done, for example after voice activity reports enough silence, end the line now:
It resolves with the line’s final text after that final transcript has reached your handlers, "" when nothing was pending, or null when no on-device recognizer is running or the picked model can’t end a line early (models that transcribe in fixed chunks deliver their final text on their own).
finishUtterance() needs a localOnly listener, or one getting on-device text right now, and only affects on-device transcription. The phone runs one recognizer for every miniapp, so it ends the current line for every on-device subscriber, Captions included.

Configuring

configure() tunes the recognizer. It’s fire-and-forget and applies to subsequent results:

Cleaning up

Every subscription returns an unsubscribe function. stop() tears down every subscription this module owns at once:
session.transcription.hasPermission tells you whether MICROPHONE is declared in your manifest. It does not tell you whether the user granted the OS prompt: if they denied it, your handler simply never fires. See Permissions.
Transcription is for text. For raw audio frames or voice-activity detection, use session.mic. For translated text, use session.translation. Subscribing to one does not subscribe you to the others.