public class BufferedDtmfInput extends java.lang.Object implements DtmfInput, SpokenInput
| Constructor and Description |
|---|
BufferedDtmfInput()
Constructs a new object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activate()
Activates this resource, when it is retrieved from the pool.
|
void |
activateGrammars(java.util.Collection<GrammarImplementation<?>> grammars)
Activates the given grammars.
|
void |
addDtmf(char dtmf)
The user entered a DTMF.
|
void |
addListener(SpokenInputListener inputListener)
Adds a listener for user input events.
|
void |
close()
Closes and releases the acquired resources.
|
void |
connect(ConnectionInformation client)
Establishes a connection from the given
ConnectionInformation to
this object. |
void |
deactivateGrammars(java.util.Collection<GrammarImplementation<?>> grammars)
Deactivates the given grammar.
|
void |
disconnect(ConnectionInformation client)
Closes a previously established connection.
|
void |
fireInputEvent(SpokenInputEvent event)
Notifies all registered listeners about the given event.
|
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.
|
java.lang.String |
getType()
Retrieves a unique identifier for this external resource.
|
boolean |
isAccepted(RecognitionResult result)
Checks if one of the active grammars accepts the current recognition
result.
|
boolean |
isBusy()
Checks if this device is busy.
|
GrammarImplementation<?> |
loadGrammar(java.net.URI uri,
org.jvoicexml.xml.srgs.GrammarType type)
Creates a
GrammarImplementation from the contents provided by the
Reader. |
void |
open()
Initializes and and acquires the needed resources.
|
void |
passivate()
Passivates this resource, when it is returned to the pool.
|
void |
removeListener(SpokenInputListener inputListener)
Removes a listener for user input events.
|
void |
setGrammarParsers(java.util.List<GrammarParser<?>> grammarParsers)
Sets the grammar parsers to use.
|
void |
startRecognition(DataModel dataModel,
SpeechRecognizerProperties speech,
DtmfRecognizerProperties dtmf)
Detects and reports character and/or spoken input simultaneously.
|
void |
stopRecognition()
Stops a previously started recognition.
|
public void setGrammarParsers(java.util.List<GrammarParser<?>> grammarParsers)
grammarParsers - the grammar parsers to usepublic void activateGrammars(java.util.Collection<GrammarImplementation<?>> grammars) throws BadFetchError, UnsupportedLanguageError, NoresourceError
activateGrammars in interface SpokenInputgrammars - Grammars to activate.BadFetchError - Grammar is not know by the recognizer.UnsupportedLanguageError - The specified language is not supported.NoresourceError - The input resource is not available.public void deactivateGrammars(java.util.Collection<GrammarImplementation<?>> grammars) throws NoresourceError, BadFetchError
deactivateGrammars in interface SpokenInputgrammars - Grammars to deactivate.BadFetchError - Grammar is not known by the recognizer.NoresourceError - The input resource is not available.public void addDtmf(char dtmf)
throws java.lang.IllegalArgumentException
public void startRecognition(DataModel dataModel, SpeechRecognizerProperties speech, DtmfRecognizerProperties dtmf) throws NoresourceError, BadFetchError
startRecognition in interface InputDevicedataModel - the data model to use for generating a semantic
interpretationspeech - the speech recognizer properties to usedtmf - the DTMF recognizer properties to useNoresourceError - The input resource is not available.BadFetchError - The active grammar contains some errors.public boolean isAccepted(RecognitionResult result)
result - the recognized DTMF resulttrue if the result is accepted.public void stopRecognition()
public void addListener(SpokenInputListener inputListener)
The implementation of this interface must notify the listener about all events.
addListener in interface SpokenInputinputListener - The listener.public void removeListener(SpokenInputListener inputListener)
removeListener in interface SpokenInputinputListener - The listener.public void fireInputEvent(SpokenInputEvent event)
event - the event.public java.lang.String getType()
getType in interface ExternalResourcepublic void open()
throws NoresourceError
open in interface ExternalResourceNoresourceError - The resource could not be opened.public void activate()
throws NoresourceError
activate in interface ExternalResourceNoresourceError - The resource could not be activated.public void passivate()
throws NoresourceError
The external resource is requested to return all resources that were assigned while it was active.
passivate in interface ExternalResourceNoresourceError - The resource could not be opened.public void close()
close in interface ExternalResourcepublic boolean isBusy()
A device can be busy only if it is activated. Closed or passivated
devices must return false.
isBusy in interface ExternalResourcetrue if the device is busy.public void connect(ConnectionInformation client) throws java.io.IOException
ConnectionInformation to
this object.connect in interface RemoteConnectableclient - data container with connection relevant data.java.io.IOException - error establishing the connection.public void disconnect(ConnectionInformation client)
disconnect in interface RemoteConnectableclient - data container with connection relevant data.public java.util.Collection<org.jvoicexml.xml.srgs.GrammarType> getSupportedGrammarTypes()
getSupportedGrammarTypes in interface SpokenInputpublic 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;
loadGrammar in interface SpokenInputuri - 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
SpokenInput.getSupportedGrammarTypes().NoresourceError - the input resource is not available.java.io.IOException - error reading the grammar.UnsupportedFormatError - invalid grammar format.public java.util.Collection<org.jvoicexml.xml.vxml.BargeInType> getSupportedBargeInTypes()
UserInput.getSupportedBargeInTypes in interface SpokenInput