API
Intent Classifier

undefined

Class: IntentClassifier

Defined in: voiceController.ts:86

Implements voice control using intent classification.

Intent classification matches user commands to actions using semantic similarity. This is most useful when we want to match commands with similar meaning (but not identical wordings) to desired actions, e.g., matching the commands to “start up”, “initialize”, and “boot it up” to an intent named “turn on”.

Extends

Constructors

new IntentClassifier()

new IntentClassifier(
   commandHandlers, 
   callbacks, 
   embeddingsModel, 
   preComputedEmbeddings): IntentClassifier

Defined in: voiceController.ts:195

Parameters

Parameter Type Default value Description
commandHandlers CommandHandlers undefined
callbacks Partial<TranscriberCallbacks> {}
embeddingsModel string 'Xenova/all-MiniLM-L6-v2'
preComputedEmbeddings string undefined

Returns

IntentClassifier

Overrides

VoiceController.constructor

Properties

Property Type Inherited from Defined in
commandHandlers CommandHandlers VoiceController.commandHandlers voiceController.ts:13
onModelLoaded () => any VoiceController.onModelLoaded voiceController.ts:16
onModelLoadStarted () => any VoiceController.onModelLoadStarted voiceController.ts:15
onSpeechEnd () => any VoiceController.onSpeechEnd voiceController.ts:22
onSpeechStart () => any VoiceController.onSpeechStart voiceController.ts:21
onTranscribeStarted () => any VoiceController.onTranscribeStarted voiceController.ts:17
onTranscribeStopped () => any VoiceController.onTranscribeStopped voiceController.ts:18
onTranscriptionCommitted (text: string) => any VoiceController.onTranscriptionCommitted voiceController.ts:19

Methods

getAllEmbeddings()

getAllEmbeddings(intents): Promise<any[]>

Defined in: voiceController.ts:141

Parameters

Parameter Type Description
intents string[]

Returns

Promise<any[]>


getCosineSimilarityScores()

getCosineSimilarityScores(embeddings, allEmbeddings): any[]

Defined in: voiceController.ts:155

Parameters

Parameter Type Description
embeddings any
allEmbeddings any -

Returns

any[]


getEmbeddings()

getEmbeddings(text): Promise<any>

Defined in: voiceController.ts:131

Parameters

Parameter Type Description
text string

Returns

Promise<any>


getIntent()

getIntent(text): Promise<string>

Defined in: voiceController.ts:181

Parameters

Parameter Type Description
text string

Returns

Promise<string>


getMostSimilar()

getMostSimilar(text, candidates): Promise<string>

Defined in: voiceController.ts:169

Parameters

Parameter Type Description
text string
candidates string[]

Returns

Promise<string>


onTranscriptionUpdated()

onTranscriptionUpdated(text): void

Defined in: voiceController.ts:216

Parameters

Parameter Type
text string

Returns

void

Overrides

VoiceController.onTranscriptionUpdated

normalizeText()

static normalizeText(text): string

Defined in: voiceController.ts:56

Parameters

Parameter Type
text string

Returns

string

Inherited from

VoiceController.normalizeText