Пример кода для списков фраз от Microsoft выполнен только с помощью SpeechRecouncer (пример)
Код: Выделить всё
AudioConfig audioInput = AudioConfig.fromWavFileInput("YourPhraseListedAudioFile.wav");
SpeechRecognizer recognizer = new SpeechRecognizer(config, audioInput);
{
// Create the recognizer.
PhraseListGrammar phraseList = PhraseListGrammar.fromRecognizer(recognizer);
// Add a phrase to assist in recognition.
phraseList.addPhrase("Wreck a nice beach");
// Subscribes to events.
recognizer.recognizing.addEventListener((s, e) -> {
System.out.println("RECOGNIZING: Text=" + e.getResult().getText());
});
recognizer.recognized.addEventListener((s, e) -> {
if (e.getResult().getReason() == ResultReason.RecognizedSpeech) {
System.out.println("RECOGNIZED: Text=" + e.getResult().getText());
}
else if (e.getResult().getReason() == ResultReason.NoMatch) {
System.out.println("NOMATCH: Speech could not be recognized.");
}
});
recognizer.canceled.addEventListener((s, e) -> {
System.out.println("CANCELED: Reason=" + e.getReason());
if (e.getReason() == CancellationReason.Error) {
System.out.println("CANCELED: ErrorCode=" + e.getErrorCode());
System.out.println("CANCELED: ErrorDetails=" + e.getErrorDetails());
System.out.println("CANCELED: Did you update the subscription info?");
}
stopRecognitionSemaphore.release();
});
recognizer.sessionStarted.addEventListener((s, e) -> {
System.out.println("\n Session started event.");
});
Подробнее здесь: https://stackoverflow.com/questions/784 ... rosoft-spe
Мобильная версия