API-Referenz
@speechineer/angular
Speechineer for Angular. Register it once with provideSpeechineer (your API key, or a
token your server signs), then call one inject function per capability in a component or
service: injectSpeechToForm to fill a form by voice, injectTextToForm to fill it from
text. Each returns the session (start, stop, end / extract) with its state as
signals (values(), transcript(), isListening(), error(), …). The client, the form
definition, the callbacks, and the state types are shared by every package and documented
once in the Core reference.
Setup
The provider function: give it your credentials (or a client you created) in your application providers and every inject function uses the same client.
provideSpeechineer()
function provideSpeechineer(clientOrOptions): EnvironmentProviders;Register Speechineer once, in your application providers. Pass the client options
(apiKey / token, account, baseUrl) — or a client you created with
createClient — and every inject… function uses it.
Parameters
| Parameter | Type |
|---|---|
clientOrOptions | ClientOptions | SpeechineerClient |
Returns
EnvironmentProviders
Example
// app.config.ts
import { provideSpeechineer } from "@speechineer/angular";
export const appConfig: ApplicationConfig = {
providers: [provideSpeechineer({ apiKey: environment.speechineerKey })],
};injectSpeechineer()
function injectSpeechineer(): SpeechineerClient;The client provideSpeechineer registered — for the rare case where you want to
create a session yourself (client.speechToForm(...)) instead of using an inject
function. Call it in an injection context (a constructor or a field initializer).
Returns
SpeechineerClient
Capability: Speech to form
Fill a form by voice: values stream into values() (and onFieldValue) as the user
speaks; add transcript: true to also receive the spoken text.
InjectSpeechToFormOptions
The options of injectSpeechToForm: the session options every framework shares, plus
an optional client to use instead of the provided one.
Extends
SpeechToFormOptions
Properties
| Property | Type | Description |
|---|---|---|
client? | SpeechineerClient | Use this client instead of the one provideSpeechineer registered. |
onSessionStart? | (sessionId) => void | Fires once, as soon as the session exists and work can begin. Receives the session id — keep it if you want to correlate it with your own logs. |
onStateChange? | (state) => void | The session state changed — its lifecycle, its id, a value, the transcript, an error, or the status of one of its connections. Receives the whole new state; render from it. |
onEvent? | (event) => void | Every status event Speechineer emits for this session — progress, warnings, and failures alike. Use it for logging or a live status display. |
onError? | (error) => void | Something failed in a way you should handle: a rejected request, a denied microphone permission, a lost connection, or a failure Speechineer reported while the session ran. Read error.code to branch and error.recoverable to decide whether to offer a retry. |
onFieldValue? | (fieldId, value) => void | One recognized field value. Called repeatedly while the user speaks, and more than once for the same fieldId when a value is refined — always apply the latest. fieldId is the id you gave the field; value is passed through as received, so cast or validate it the way your form expects. |
onTranscript? | (text) => void | The transcript so far — the full accumulated text, not just the newest words, so you can render it directly without stitching updates together. |
form | FormDefinition | Which form to fill: the one configured in Speechineer, or one defined right here. |
spokenLanguage? | string | The language the user will speak (for example 'en', 'de'). Detected automatically when omitted; set it when you already know, for slightly faster and more reliable recognition. |
transcript? | boolean | Also stream the spoken text: transcript in the state (and onTranscript) fills while the user speaks. Fixed for the session — change it by creating a new one. |
initialValues? | Record<string, unknown> | Values you already captured, keyed by field id — for example when a user resumes a form that was partly filled in earlier. They appear in values immediately and Speechineer continues from them. |
account? | Account | The end user this session is for, when it differs from the client's default account. Ignored when the client authenticates with a signed token — the token carries the account. |
InjectSpeechToFormResult
type InjectSpeechToFormResult = SpeechToFormSession & SessionSignals;What injectSpeechToForm returns: the session (start, stop, end, …) plus its
state as signals.
injectSpeechToForm()
function injectSpeechToForm(options): InjectSpeechToFormResult;Fill a form by voice. Call it in an injection context; the session is released
with the component. Render from the signals (isListening(), values(), …) and
drive it with start() / stop() / end().
Pass a plain object when the options never change. Pass a function when they depend on
signals: it is re-read whenever those signals change, so callbacks and initialValues
follow the component instead of staying at the values they had when the session was
created. That matters for initialValues in particular — a session that reconnects sends
the values the form holds at that moment, not the ones it started with.
Parameters
| Parameter | Type |
|---|---|
options | | InjectSpeechToFormOptions | (() => InjectSpeechToFormOptions) |
Returns
Example
import { Component } from "@angular/core";
import { injectSpeechToForm, FormField } from "@speechineer/angular";
@Component({
selector: "talk-to-form",
template: `
<button type="button" (click)="voice.isListening() ? voice.stop() : voice.start()">
{{ voice.isListening() ? "Stop" : "Talk" }}
</button>
<input [value]="voice.values()['patientName'] ?? ''" readonly />
`,
})
export class TalkToForm {
readonly voice = injectSpeechToForm({
form: { source: "inline", key: "patient-intake", version: "1", language: "en",
fields: [FormField.text("patientName", "Extract the patient full name")] },
});
}Capability: Text to form
No recording at all — turn text the user typed or pasted into field values, as often as you like.
InjectTextToFormOptions
The options of injectTextToForm: the session options every framework shares, plus
an optional client to use instead of the provided one.
Extends
TextToFormOptions
Properties
| Property | Type | Description |
|---|---|---|
client? | SpeechineerClient | Use this client instead of the one provideSpeechineer registered. |
onSessionStart? | (sessionId) => void | Fires once, as soon as the session exists and work can begin. Receives the session id — keep it if you want to correlate it with your own logs. |
onStateChange? | (state) => void | The session state changed — its lifecycle, its id, a value, the transcript, an error, or the status of one of its connections. Receives the whole new state; render from it. |
onEvent? | (event) => void | Every status event Speechineer emits for this session — progress, warnings, and failures alike. Use it for logging or a live status display. |
onError? | (error) => void | Something failed in a way you should handle: a rejected request, a denied microphone permission, a lost connection, or a failure Speechineer reported while the session ran. Read error.code to branch and error.recoverable to decide whether to offer a retry. |
onFieldValue? | (fieldId, value) => void | One recognized field value. Called repeatedly while the user speaks, and more than once for the same fieldId when a value is refined — always apply the latest. fieldId is the id you gave the field; value is passed through as received, so cast or validate it the way your form expects. |
form | FormDefinition | Which form to fill: the one configured in Speechineer, or one defined right here. |
initialValues? | Record<string, unknown> | Values you already captured, keyed by field id. They appear in values immediately and Speechineer treats them as the baseline for the next extraction. |
account? | Account | The end user this session is for, when it differs from the client's default account. Ignored when the client authenticates with a signed token. |
InjectTextToFormResult
type InjectTextToFormResult = TextToFormSession & SessionSignals;What injectTextToForm returns: the session (extract, start, end, …) plus its
state as signals.
injectTextToForm()
function injectTextToForm(options): InjectTextToFormResult;Extract field values from text. Call it in an injection context; extract(text)
opens the session on first use and merges every result into values().
As with injectSpeechToForm, pass a function instead of a plain object when the options
depend on signals and should follow the component.
Parameters
| Parameter | Type |
|---|---|
options | | InjectTextToFormOptions | (() => InjectTextToFormOptions) |
Returns
Session state
The state as signals — one per field you typically render.
SessionSignals
The session state as signals — the same shape every framework reports, one signal
per field you typically render, plus state for the whole object.
Properties
| Property | Type | Description |
|---|---|---|
state | Signal<SessionState> | The whole state object as a signal; it updates on every change. |
status | Signal<SessionStatus> | Where the session is in its life. |
sessionId | Signal<string | null> | The id of the running session, or null. |
error | Signal<SpeechineerError | null> | The last error, or null. |
values | Signal<Readonly<Record<string, unknown>>> | The latest recognized value of every field, keyed by field id. |
transcript | Signal<string> | The spoken text so far. |
isListening | Signal<boolean> | The microphone is on and audio is being sent. |
isConnecting | Signal<boolean> | The session or one of its connections is being established. |
isEnding | Signal<boolean> | The session is being finished, or the microphone is winding down. |