GrammarList Class

Implements

java.lang.AutoCloseable

public final class GrammarList
extends Grammar
implements java.lang.AutoCloseable

Allows adding multiple grammars to a SpeechRecognizer to improve the accuracy of speech recognition. GrammarLists are only usable in specific scenarios and are not generally available. Note: close() must be called in order to release underlying resources held by the object.

Method Summary

Modifier and Type Method and Description
void add(Grammar grammar)

Adds a single grammar to the current recognizer.

void close()

Dispose of associated resources.

static GrammarList fromRecognizer(Recognizer recognizer)

Creates a GrammarList from a given speech recognizer.

Methods inherited from Grammar

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

add

public void add(Grammar grammar)

Adds a single grammar to the current recognizer.

Parameters:

grammar - Grammar to add.

close

public void close()

Dispose of associated resources.

Overrides:

GrammarList.close()

fromRecognizer

public static GrammarList fromRecognizer(Recognizer recognizer)

Creates a GrammarList from a given speech recognizer. Creating a grammar list from a recognizer is only usable in specific scenarios and is not generally available.

Parameters:

recognizer - The recognizer to get the grammar list from.

Returns:

GrammarList associated to the recognizer.

Applies to