1 // Copyright 2014 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.
5 #include "chrome/browser/chromeos/accessibility/speech_monitor.h"
10 const char kChromeVoxEnabledMessage
[] = "chrome vox spoken feedback is ready";
11 } // anonymous namespace
13 SpeechMonitor::SpeechMonitor() {
14 TtsController::GetInstance()->SetPlatformImpl(this);
17 SpeechMonitor::~SpeechMonitor() {
18 TtsController::GetInstance()->SetPlatformImpl(TtsPlatformImpl::GetInstance());
21 std::string
SpeechMonitor::GetNextUtterance() {
22 if (utterance_queue_
.empty()) {
23 loop_runner_
= new content::MessageLoopRunner();
27 std::string result
= utterance_queue_
.front();
28 utterance_queue_
.pop_front();
32 bool SpeechMonitor::SkipChromeVoxEnabledMessage() {
33 return GetNextUtterance() == kChromeVoxEnabledMessage
;
36 bool SpeechMonitor::PlatformImplAvailable() {
40 bool SpeechMonitor::Speak(
42 const std::string
& utterance
,
43 const std::string
& lang
,
44 const VoiceData
& voice
,
45 const UtteranceContinuousParameters
& params
) {
46 TtsController::GetInstance()->OnTtsEvent(
49 static_cast<int>(utterance
.size()),
54 bool SpeechMonitor::StopSpeaking() {
58 bool SpeechMonitor::IsSpeaking() {
62 void SpeechMonitor::GetVoices(std::vector
<VoiceData
>* out_voices
) {
63 out_voices
->push_back(VoiceData());
64 VoiceData
& voice
= out_voices
->back();
66 voice
.name
= "SpeechMonitor";
67 voice
.events
.insert(TTS_EVENT_END
);
70 std::string
SpeechMonitor::error() {
74 void SpeechMonitor::WillSpeakUtteranceWithVoice(const Utterance
* utterance
,
75 const VoiceData
& voice_data
) {
76 VLOG(0) << "Speaking " << utterance
->text();
77 utterance_queue_
.push_back(utterance
->text());
78 if (loop_runner_
.get())
82 } // namespace chromeos