Methods Summary |
---|
private static native void | PMemInit()
|
private static native void | PMemShutdown()
|
private static native java.lang.String | SR_AcousticStateGet(long recognizer)
|
private static native void | SR_AcousticStateReset(long recognizer)
|
private static native void | SR_AcousticStateSet(long recognizer, java.lang.String state)
|
private static native void | SR_GrammarAddWordToSlot(long 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(long grammar)
|
private static native void | SR_GrammarAllowOnly(long grammar, java.lang.String transcription)
|
private static native void | SR_GrammarCompile(long grammar)
|
private static native long | SR_GrammarCreate()
|
private static native void | SR_GrammarDestroy(long grammar)
|
private static native long | SR_GrammarLoad(java.lang.String filename)
|
private static native void | SR_GrammarResetAllSlots(long grammar)
|
private static native void | SR_GrammarSave(long grammar, java.lang.String filename)
|
private static native void | SR_GrammarSetupRecognizer(long grammar, long recognizer)
|
private static native void | SR_GrammarSetupVocabulary(long grammar, long vocabulary)
|
private static native void | SR_GrammarUnsetupRecognizer(long grammar)
|
private static native void | SR_RecognizerActivateRule(long recognizer, long grammar, java.lang.String ruleName, int weight)
|
private static native int | SR_RecognizerAdvance(long recognizer)
|
private static native boolean | SR_RecognizerCheckGrammarConsistency(long recognizer, long grammar)
|
private static native long | SR_RecognizerCreate()
|
private static native void | SR_RecognizerDeactivateAllRules(long recognizer)
|
private static native void | SR_RecognizerDeactivateRule(long recognizer, long grammar, java.lang.String ruleName)
|
private static native void | SR_RecognizerDestroy(long recognizer)
|
private static native boolean | SR_RecognizerGetBoolParameter(long recognizer, java.lang.String key)
|
private static native java.lang.String | SR_RecognizerGetParameter(long recognizer, java.lang.String key)
|
private static native int | SR_RecognizerGetSize_tParameter(long recognizer, java.lang.String key)
|
private static native boolean | SR_RecognizerHasSetupRules(long recognizer)
|
private static native boolean | SR_RecognizerIsActiveRule(long recognizer, long grammar, java.lang.String ruleName)
|
private static native boolean | SR_RecognizerIsSetup(long recognizer)
|
private static native boolean | SR_RecognizerIsSignalClipping(long recognizer)
|
private static native boolean | SR_RecognizerIsSignalDCOffset(long recognizer)
|
private static native boolean | SR_RecognizerIsSignalNoisy(long recognizer)
|
private static native boolean | SR_RecognizerIsSignalTooFewSamples(long recognizer)
|
private static native boolean | SR_RecognizerIsSignalTooManySamples(long recognizer)
|
private static native boolean | SR_RecognizerIsSignalTooQuiet(long recognizer)
|
private static native int | SR_RecognizerPutAudio(long recognizer, byte[] buffer, int offset, int length, boolean isLast)
|
private static native int | SR_RecognizerResultGetKeyCount(long recognizer, int nbest)
|
private static native java.lang.String[] | SR_RecognizerResultGetKeyList(long recognizer, int nbest)
|
private static native int | SR_RecognizerResultGetSize(long recognizer)
|
private static native java.lang.String | SR_RecognizerResultGetValue(long recognizer, int nbest, java.lang.String key)
|
private static native byte[] | SR_RecognizerResultGetWaveform(long recognizer)
|
private static native void | SR_RecognizerSetBoolParameter(long recognizer, java.lang.String key, boolean value)
|
private static native void | SR_RecognizerSetParameter(long recognizer, java.lang.String key, java.lang.String value)
|
private static native void | SR_RecognizerSetSize_tParameter(long recognizer, java.lang.String key, int value)
|
private static native void | SR_RecognizerSetup(long recognizer)
|
private static native void | SR_RecognizerSetupRule(long recognizer, long grammar, java.lang.String ruleName)
|
private static native void | SR_RecognizerStart(long recognizer)
|
private static native void | SR_RecognizerStop(long recognizer)
|
private static native void | SR_RecognizerUnsetup(long recognizer)
|
private static native void | SR_SessionCreate(java.lang.String filename)
|
private static native void | SR_SessionDestroy()
|
private static native void | SR_VocabularyDestroy(long vocabulary)
|
private static native java.lang.String | SR_VocabularyGetPronunciation(long vocabulary, java.lang.String word)
|
private static native long | 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(Locale.ROOT);
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");
|