public interface SpokenInput extends ExternalResource, InputDevice
Objects that implement this interface are able to detect spoken input and to control input detection interval duration with a timer whose length is specified by a VoiceXML document.
If an input resource is not available, an error.noresource event
must be thrown.
It is guaranteed that the session remains the same between the calls to
RemoteConnectable.connect(org.jvoicexml.ConnectionInformation)
and
RemoteConnectable.disconnect(org.jvoicexml.ConnectionInformation).
| Modifier and Type | Method and Description |
|---|---|
void |
activateGrammars(java.util.Collection<GrammarImplementation<?>> grammars)
Activates the given grammars.
|
void |
addListener(SpokenInputListener listener)
Adds a listener for user input events.
|
void |
deactivateGrammars(java.util.Collection<GrammarImplementation<?>> grammars)
Deactivates the given grammar.
|
java.util.Collection<org.jvoicexml.xml.vxml.BargeInType> |
getSupportedBargeInTypes()
Retrieves the barge-in types supported by this
UserInput. |
java.util.Collection<org.jvoicexml.xml.srgs.GrammarType> |
getSupportedGrammarTypes()
Retrieves the grammar types that are supported by this implementation.
|
GrammarImplementation<?> |
loadGrammar(java.net.URI uri,
org.jvoicexml.xml.srgs.GrammarType type)
Creates a
GrammarImplementation from the contents provided by the
Reader. |
void |
removeListener(SpokenInputListener listener)
Removes a listener for user input events.
|
activate, close, getType, isBusy, open, passivateconnect, disconnectstartRecognition, stopRecognitionjava.util.Collection<org.jvoicexml.xml.srgs.GrammarType> getSupportedGrammarTypes()
void activateGrammars(java.util.Collection<GrammarImplementation<?>> grammars) throws BadFetchError, UnsupportedLanguageError, UnsupportedFormatError, NoresourceError
It is guaranteed that the loadGrammar(URI, GrammarType) method
is always called before a grammar becomes active via this method.
grammars - Grammars to activate.BadFetchError - Grammar is not known by the recognizer.UnsupportedLanguageError - The specified language is not supported.UnsupportedFormatError - the grammar format is not supportedNoresourceError - The input resource is not available.void deactivateGrammars(java.util.Collection<GrammarImplementation<?>> grammars) throws NoresourceError, BadFetchError
grammars - Grammars to deactivate.BadFetchError - Grammar is not known by the recognizer.NoresourceError - The input resource is not available.GrammarImplementation<?> loadGrammar(java.net.URI uri, org.jvoicexml.xml.srgs.GrammarType type) throws NoresourceError, java.io.IOException, UnsupportedFormatError
GrammarImplementation from the contents provided by the
Reader. If the grammar contained in the Reader already exists, it is
over-written.
This method is mainly needed for non SRGS grammars, e.g. JSGF. The grammar implementation is platform specific, so it the responsibility of the implementation platform to return load it's specific grammar. However, loading an SRGS grammar is quite easy and can be implemented e.g. as
final InputSource inputSource = new InputSource(reader);
SrgsXmlDocument doc = new SrgsXmlDocument(inputSource);
// Pass it to the recognizer
return doc;
uri - the URI to load the grammartype - type of the grammar to read. The type is one of the supported
types of the implementation, that has been requested via
getSupportedGrammarTypes().NoresourceError - the input resource is not available.java.io.IOException - error reading the grammar.UnsupportedFormatError - invalid grammar format.java.util.Collection<org.jvoicexml.xml.vxml.BargeInType> getSupportedBargeInTypes()
UserInput.void addListener(SpokenInputListener listener)
The implementation of this interface must notify the listener about all events.
listener - The listener.void removeListener(SpokenInputListener listener)
listener - The listener.