For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to page URLs.
Skip to content

Speech-to-Text Controller

Controller and recorder for speech-to-text transcription in custom elements.

UaiSpeechToTextController and UaiAudioRecorder provide a frontend API for recording audio and transcribing it to text. The two classes separate concerns: the recorder captures audio from the microphone, and the controller sends it to the Management API for transcription.

Import

Import
import {
    UaiSpeechToTextController,
    UaiAudioRecorder,
    UaiSpeechToTextOptions,
    UaiSpeechToTextResult,
    UaiAudioRecorderState
} from "@umbraco-ai/core";

UaiAudioRecorder

Records audio via the browser's MediaRecorder API. Extends UmbControllerBase so the recording is automatically cancelled when the host element is destroyed (for example, when navigating away).

Constructor

Constructor
new UaiAudioRecorder(host: UmbControllerHost)
Parameter
Type
Description

host

UmbControllerHost

The controller host (usually this in a Lit element)

Properties

Property
Type
Description

state

UaiAudioRecorderState

Current state: "idle" or "recording"

state$

Observable<UaiAudioRecorderState>

RxJS observable of state changes

Methods

start

Requests microphone access and begins recording.

stop

Stops recording and returns the captured audio as a Blob.

cancel

Stops recording and discards the captured audio.

Example

UaiSpeechToTextController

Handles transcription by sending audio to the Management API. Follows the same controller pattern as UaiChatController.

Constructor

Parameter
Type
Description

host

UmbControllerHost

The controller host (usually this in a Lit element)

Methods

transcribe

Sends an audio blob to the Management API for transcription.

Parameter
Type
Description

audioFile

Blob

The recorded audio blob

options

UaiSpeechToTextOptions

Optional transcription config

Returns: Promise resolving to { data?, error? }

Options

Result

Complete Example

Last updated

Was this helpful?