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