| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| [DartPackage="mojo_services", |
| JavaPackage="org.chromium.mojo.speech_recognizer"] |
| module speech_recognizer; |
| |
| enum Error { |
| NETWORK_TIMEOUT = 1, |
| NETWORK = 2, |
| AUDIO = 3, |
| SERVER = 4, |
| CLIENT = 5, |
| SPEECH_TIMEOUT = 6, |
| NO_MATCH = 7, |
| RECOGNIZER_BUSY = 8, |
| INSUFFICIENT_PERMISSIONS = 9, |
| }; |
| |
| struct UtteranceCandidate { |
| // Utterance text candidate returned by speech recognition service. |
| string text; |
| |
| // Confidence score in [0,1]. |
| float confidence_score; |
| }; |
| |
| // Receives events from the |SpeechRecognizerService|. |
| interface SpeechRecognizerListener { |
| // Called when an error occurs. |
| OnRecognizerError(Error error_code); |
| |
| // Called when the recognizer receives results. |complete| will be true if |
| // the recognizer has stopped listening with these results. |
| OnResults(array<UtteranceCandidate> results, bool complete); |
| |
| // Called when sound level changes. |
| OnSoundLevelChanged(float rmsDb); |
| }; |
| |
| // |SpeechRecognizerService| provides access to a speech recognition service. |
| // It is responsible for reading microphone input, deciding when the user is |
| // done speaking, and performing speech recognition on the result. |
| [ServiceName="speech_recognizer::SpeechRecognizerService"] |
| interface SpeechRecognizerService { |
| // Starts listening to the user. When listening has finished or an error |
| // occurs, returns |result_or_error|. Any call to Listen() made while another |
| // is in progress will immediately return an error. |
| Listen(SpeechRecognizerListener listener); |
| |
| // Stops the SpeechRecognizer from listening and finishes any previous call |
| // to Listen() causing it to return. |
| StopListening(); |
| }; |