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 #ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_
6 #define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/speech/tts_platform.h"
12 #include "content/public/test/test_utils.h"
16 // For testing purpose installs itself as the platform speech synthesis engine,
17 // allowing it to intercept all speech calls, and then provides a method to
18 // block until the next utterance is spoken.
19 class SpeechMonitor
: public TtsPlatformImpl
{
22 ~SpeechMonitor() override
;
24 // Blocks until the next utterance is spoken, and returns its text.
25 std::string
GetNextUtterance();
27 // Wait for next utterance and return true if next utterance is ChromeVox
29 bool SkipChromeVoxEnabledMessage();
31 // TtsPlatformImpl implementation.
32 bool PlatformImplAvailable() override
;
33 bool Speak(int utterance_id
,
34 const std::string
& utterance
,
35 const std::string
& lang
,
36 const VoiceData
& voice
,
37 const UtteranceContinuousParameters
& params
) override
;
38 bool StopSpeaking() override
;
39 bool IsSpeaking() override
;
40 void GetVoices(std::vector
<VoiceData
>* out_voices
) override
;
41 void Pause() override
{}
42 void Resume() override
{}
43 std::string
error() override
;
44 void clear_error() override
{}
45 void set_error(const std::string
& error
) override
{}
46 void WillSpeakUtteranceWithVoice(const Utterance
* utterance
,
47 const VoiceData
& voice_data
) override
;
50 scoped_refptr
<content::MessageLoopRunner
> loop_runner_
;
51 std::deque
<std::string
> utterance_queue_
;
53 DISALLOW_COPY_AND_ASSIGN(SpeechMonitor
);
56 } // namespace chromeos
58 #endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_SPEECH_MONITOR_H_