Methods Summary |
---|
private static native void | PMemInit()
|
private static native void | PMemShutdown()
|
private static native java.lang.String | SR_AcousticStateGet(int recognizer)
|
private static native void | SR_AcousticStateReset(int recognizer)
|
private static native void | SR_AcousticStateSet(int recognizer, java.lang.String state)
|
private static native void | SR_GrammarAddWordToSlot(int grammar, java.lang.String slot, java.lang.String word, java.lang.String pronunciation, int weight, java.lang.String tag)
|
private static native void | SR_GrammarAllowAll(int grammar)
|
private static native void | SR_GrammarAllowOnly(int grammar, java.lang.String transcription)
|
private static native void | SR_GrammarCompile(int grammar)
|
private static native int | SR_GrammarCreate()
|
private static native void | SR_GrammarDestroy(int grammar)
|
private static native int | SR_GrammarLoad(java.lang.String filename)
|
private static native void | SR_GrammarResetAllSlots(int grammar)
|
private static native void | SR_GrammarSave(int grammar, java.lang.String filename)
|
private static native void | SR_GrammarSetupRecognizer(int grammar, int recognizer)
|
private static native void | SR_GrammarSetupVocabulary(int grammar, int vocabulary)
|
private static native void | SR_GrammarUnsetupRecognizer(int grammar)
|
private static native void | SR_RecognizerActivateRule(int recognizer, int grammar, java.lang.String ruleName, int weight)
|
private static native int | SR_RecognizerAdvance(int recognizer)
|
private static native boolean | SR_RecognizerCheckGrammarConsistency(int recognizer, int grammar)
|
private static native int | SR_RecognizerCreate()
|
private static native void | SR_RecognizerDeactivateAllRules(int recognizer)
|
private static native void | SR_RecognizerDeactivateRule(int recognizer, int grammar, java.lang.String ruleName)
|
private static native void | SR_RecognizerDestroy(int recognizer)
|
private static native boolean | SR_RecognizerGetBoolParameter(int recognizer, java.lang.String key)
|
private static native java.lang.String | SR_RecognizerGetParameter(int recognizer, java.lang.String key)
|
private static native int | SR_RecognizerGetSize_tParameter(int recognizer, java.lang.String key)
|
private static native boolean | SR_RecognizerHasSetupRules(int recognizer)
|
private static native boolean | SR_RecognizerIsActiveRule(int recognizer, int grammar, java.lang.String ruleName)
|
private static native boolean | SR_RecognizerIsSetup(int recognizer)
|
private static native boolean | SR_RecognizerIsSignalClipping(int recognizer)
|
private static native boolean | SR_RecognizerIsSignalDCOffset(int recognizer)
|
private static native boolean | SR_RecognizerIsSignalNoisy(int recognizer)
|
private static native boolean | SR_RecognizerIsSignalTooFewSamples(int recognizer)
|
private static native boolean | SR_RecognizerIsSignalTooManySamples(int recognizer)
|
private static native boolean | SR_RecognizerIsSignalTooQuiet(int recognizer)
|
private static native int | SR_RecognizerPutAudio(int recognizer, byte[] buffer, int offset, int length, boolean isLast)
|
private static native int | SR_RecognizerResultGetKeyCount(int recognizer, int nbest)
|
private static native java.lang.String[] | SR_RecognizerResultGetKeyList(int recognizer, int nbest)
|
private static native int | SR_RecognizerResultGetSize(int recognizer)
|
private static native java.lang.String | SR_RecognizerResultGetValue(int recognizer, int nbest, java.lang.String key)
|
private static native byte[] | SR_RecognizerResultGetWaveform(int recognizer)
|
private static native void | SR_RecognizerSetBoolParameter(int recognizer, java.lang.String key, boolean value)
|
private static native void | SR_RecognizerSetParameter(int recognizer, java.lang.String key, java.lang.String value)
|
private static native void | SR_RecognizerSetSize_tParameter(int recognizer, java.lang.String key, int value)
|
private static native void | SR_RecognizerSetup(int recognizer)
|
private static native void | SR_RecognizerSetupRule(int recognizer, int grammar, java.lang.String ruleName)
|
private static native void | SR_RecognizerStart(int recognizer)
|
private static native void | SR_RecognizerStop(int recognizer)
|
private static native void | SR_RecognizerUnsetup(int recognizer)
|
private static native void | SR_SessionCreate(java.lang.String filename)
|
private static native void | SR_SessionDestroy()
|
private static native void | SR_VocabularyDestroy(int vocabulary)
|
private static native java.lang.String | SR_VocabularyGetPronunciation(int vocabulary, java.lang.String word)
|
private static native int | SR_VocabularyLoad()
|
public int | advance()Process some audio and return the current status.
return SR_RecognizerAdvance(mRecognizer);
|
public void | destroy()Clean up resources.
try {
if (mVocabulary != 0) SR_VocabularyDestroy(mVocabulary);
} finally {
mVocabulary = 0;
try {
if (mRecognizer != 0) SR_RecognizerUnsetup(mRecognizer);
} finally {
try {
if (mRecognizer != 0) SR_RecognizerDestroy(mRecognizer);
} finally {
mRecognizer = 0;
try {
SR_SessionDestroy();
} finally {
PMemShutdown();
}
}
}
}
|
public static java.lang.String | eventToString(int event)Produce a displayable string from an advance event.
switch (event) {
case EVENT_INVALID:
return "EVENT_INVALID";
case EVENT_NO_MATCH:
return "EVENT_NO_MATCH";
case EVENT_INCOMPLETE:
return "EVENT_INCOMPLETE";
case EVENT_STARTED:
return "EVENT_STARTED";
case EVENT_STOPPED:
return "EVENT_STOPPED";
case EVENT_START_OF_VOICING:
return "EVENT_START_OF_VOICING";
case EVENT_END_OF_VOICING:
return "EVENT_END_OF_VOICING";
case EVENT_SPOKE_TOO_SOON:
return "EVENT_SPOKE_TOO_SOON";
case EVENT_RECOGNITION_RESULT:
return "EVENT_RECOGNITION_RESULT";
case EVENT_START_OF_UTTERANCE_TIMEOUT:
return "EVENT_START_OF_UTTERANCE_TIMEOUT";
case EVENT_RECOGNITION_TIMEOUT:
return "EVENT_RECOGNITION_TIMEOUT";
case EVENT_NEED_MORE_AUDIO:
return "EVENT_NEED_MORE_AUDIO";
case EVENT_MAX_SPEECH:
return "EVENT_MAX_SPEECH";
}
return "EVENT_" + event;
|
protected void | finalize()Clean up resources.
if (mVocabulary != 0 || mRecognizer != 0) {
destroy();
throw new IllegalStateException("someone forgot to destroy Recognizer");
}
|
public java.lang.String | getAcousticState()Get the acoustic state vector.
return SR_AcousticStateGet(mRecognizer);
|
public static java.lang.String | getConfigDir(java.util.Locale locale)Get the pathname of the SREC configuration directory corresponding to the
language indicated by the Locale.
This directory contains dictionaries, speech models,
configuration files, and other data needed by the Recognizer.
if (locale == null) locale = Locale.US;
String dir = "/system/usr/srec/config/" +
locale.toString().replace('_", '.").toLowerCase();
if ((new File(dir)).isDirectory()) return dir;
return null;
|
public java.lang.String | getResult(int index, java.lang.String key)Get a result value. Must be called after
EVENT_RECOGNITION_RESULT is returned by
advance , but before stop .
return SR_RecognizerResultGetValue(mRecognizer, index, key);
|
public int | getResultCount()Get the number of recognition results. Must be called after
EVENT_RECOGNITION_RESULT is returned by
advance , but before stop .
return SR_RecognizerResultGetSize(mRecognizer);
|
public java.lang.String[] | getResultKeys(int index)Get a set of keys for the result. Must be called after
EVENT_RECOGNITION_RESULT is returned by
advance , but before stop .
return SR_RecognizerResultGetKeyList(mRecognizer, index);
|
public int | putAudio(byte[] buf, int offset, int length, boolean isLast)Put audio samples into the Recognizer .
return SR_RecognizerPutAudio(mRecognizer, buf, offset, length, isLast);
|
public void | putAudio(java.io.InputStream audio)Read audio samples from an InputStream and put them in the
Recognizer .
// make sure the audio buffer is allocated
if (mPutAudioBuffer == null) mPutAudioBuffer = new byte[512];
// read some data
int nbytes = audio.read(mPutAudioBuffer);
// eof, so signal Recognizer
if (nbytes == -1) {
SR_RecognizerPutAudio(mRecognizer, mPutAudioBuffer, 0, 0, true);
}
// put it into the Recognizer
else if (nbytes != SR_RecognizerPutAudio(mRecognizer, mPutAudioBuffer, 0, nbytes, false)) {
throw new IOException("SR_RecognizerPutAudio failed nbytes=" + nbytes);
}
|
public void | resetAcousticState()Reset the acoustic state vectorto it's default value.
SR_AcousticStateReset(mRecognizer);
|
public void | setAcousticState(java.lang.String state)Set the acoustic state vector.
SR_AcousticStateSet(mRecognizer, state);
|
public void | start()Start recognition
// TODO: shouldn't be here?
SR_RecognizerActivateRule(mRecognizer, mActiveGrammar.mGrammar, "trash", 1);
SR_RecognizerStart(mRecognizer);
|
public void | stop()Stop the Recognizer .
SR_RecognizerStop(mRecognizer);
SR_RecognizerDeactivateRule(mRecognizer, mActiveGrammar.mGrammar, "trash");
|