| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ | |
| 6 #define CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace net { | |
| 15 class URLRequestContextGetter; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 class SpeechRecognitionEventListener; | |
| 21 | |
| 22 // Records audio, sends recorded audio to server and translates server response | |
| 23 // to recognition result. | |
| 24 // TODO(primiano) remove this public interface as soon as we fix speech input | |
| 25 // extensions. | |
| 26 class SpeechRecognizer : public base::RefCountedThreadSafe<SpeechRecognizer> { | |
| 27 public: | |
| 28 CONTENT_EXPORT static SpeechRecognizer* Create( | |
| 29 SpeechRecognitionEventListener* event_listener, | |
| 30 int session_id, | |
| 31 const std::string& language, | |
| 32 const std::string& grammar, | |
| 33 net::URLRequestContextGetter* context_getter, | |
| 34 bool filter_profanities, | |
| 35 const std::string& hardware_info, | |
| 36 const std::string& origin_url); | |
| 37 | |
| 38 // Starts audio recording and the recognition process. The same | |
| 39 // SpeechRecognizer instance can be used multiple times for speech recognition | |
| 40 // though each recognition request can be made only after the previous one | |
| 41 // completes (i.e. after receiving | |
| 42 // SpeechRecognitionEventListener::OnRecognitionEnd). | |
| 43 virtual void StartRecognition() = 0; | |
| 44 | |
| 45 // Stops recording audio and cancels recognition. Any audio recorded so far | |
| 46 // gets discarded. | |
| 47 virtual void AbortRecognition() = 0; | |
| 48 | |
| 49 // Stops recording audio and finalizes recognition, possibly getting results. | |
| 50 virtual void StopAudioCapture() = 0; | |
| 51 | |
| 52 // Checks wether the recognizer is active, that is, either capturing audio | |
| 53 // or waiting for a result. | |
| 54 virtual bool IsActive() const = 0; | |
| 55 | |
| 56 // Checks whether the recognizer is capturing audio. | |
| 57 virtual bool IsCapturingAudio() const = 0; | |
| 58 | |
| 59 protected: | |
| 60 friend class base::RefCountedThreadSafe<SpeechRecognizer>; | |
| 61 virtual ~SpeechRecognizer() {} | |
| 62 }; | |
| 63 | |
| 64 } // namespace content | |
| 65 | |
| 66 #endif // CONTENT_PUBLIC_BROWSER_SPEECH_RECOGNIZER_H_ | |
| OLD | NEW |