Pebble.Dictation

Voice dictation via the Pebble microphone and phone speech recognition.

Start a session with start, subscribe to onStatus and onResult, and call stop to cancel early if needed.

import Pebble.Dictation as Dictation

type Msg
    = StartDictation
    | DictationStatus Dictation.Status
    | DictationResult (Result Dictation.Error String)

update msg model =
    case msg of
        StartDictation ->
            ( model, Dictation.start )

        DictationResult (Ok text) ->
            ( { model | transcript = text }, Cmd.none )

        _ ->
            ( model, Cmd.none )

subscriptions _ =
    Sub.batch
        [ Dictation.onStatus DictationStatus
        , Dictation.onResult DictationResult
        ]

For a runnable example, use the watch-demo-dictation project template in the IDE.

Native Pebble C API

Union Types

Error

type Error
    = NoMicrophone
    | PhoneDisconnected
    | Cancelled
    | Failed String

Dictation session errors.

Status

type Status
    = Starting
    | Recognizing
    | Finished

Dictation session lifecycle status.

Commands

start

start : Cmd msg

Start a dictation session.

stop

stop : Cmd msg

Stop an in-progress dictation session.

Subscriptions

onStatus

onStatus : (Status -> msg) -> Sub msg

Receive dictation status updates.

onResult

onResult : (Result Error String -> msg) -> Sub msg

Receive the transcribed text or an error when the session completes.