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.
5 #ifndef CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_
6 #define CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_
10 #include "chrome/browser/speech/tts_controller.h"
12 // Abstract class that defines the native platform TTS interface,
13 // subclassed by specific implementations on Win, Mac, etc.
14 class TtsPlatformImpl
{
16 static TtsPlatformImpl
* GetInstance();
18 // Returns true if this platform implementation is supported and available.
19 virtual bool PlatformImplAvailable() = 0;
21 // Speak the given utterance with the given parameters if possible,
22 // and return true on success. Utterance will always be nonempty.
23 // If rate, pitch, or volume are -1.0, they will be ignored.
25 // The TtsController will only try to speak one utterance at
26 // a time. If it wants to interrupt speech, it will always call Stop
27 // before speaking again.
30 const std::string
& utterance
,
31 const std::string
& lang
,
32 const VoiceData
& voice
,
33 const UtteranceContinuousParameters
& params
) = 0;
35 // Stop speaking immediately and return true on success.
36 virtual bool StopSpeaking() = 0;
38 // Returns whether any speech is on going.
39 virtual bool IsSpeaking() = 0;
41 // Append information about voices provided by this platform implementation
43 virtual void GetVoices(std::vector
<VoiceData
>* out_voices
) = 0;
45 // Pause the current utterance, if any, until a call to Resume,
46 // Speak, or StopSpeaking.
47 virtual void Pause() = 0;
49 // Resume speaking the current utterance, if it was paused.
50 virtual void Resume() = 0;
52 // Allows the platform to monitor speech commands and the voices used
54 virtual void WillSpeakUtteranceWithVoice(const Utterance
* utterance
,
55 const VoiceData
& voice_data
);
57 virtual std::string
error();
58 virtual void clear_error();
59 virtual void set_error(const std::string
& error
);
64 // On some platforms this may be a leaky singleton - do not rely on the
65 // destructor being called! http://crbug.com/122026
66 virtual ~TtsPlatformImpl() {}
70 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImpl
);
73 #endif // CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_