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