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 // Some platforms may provide a built-in TTS extension. Returns true
22 // if the extension was not previously loaded and is now loading, and
23 // false if it's already loaded or if there's no extension to load.
24 // Will call TtsController::RetrySpeakingQueuedUtterances when
25 // the extension finishes loading.
26 virtual bool LoadBuiltInTtsExtension(Profile
* profile
);
28 // Speak the given utterance with the given parameters if possible,
29 // and return true on success. Utterance will always be nonempty.
30 // If rate, pitch, or volume are -1.0, they will be ignored.
32 // The TtsController will only try to speak one utterance at
33 // a time. If it wants to interrupt speech, it will always call Stop
34 // before speaking again.
37 const std::string
& utterance
,
38 const std::string
& lang
,
39 const UtteranceContinuousParameters
& params
) = 0;
41 // Stop speaking immediately and return true on success.
42 virtual bool StopSpeaking() = 0;
44 // Returns whether any speech is on going.
45 virtual bool IsSpeaking() = 0;
47 // Return true if this platform implementation will fire the given event.
48 // All platform implementations must fire the TTS_EVENT_END event at a
50 virtual bool SendsEvent(TtsEventType event_type
) = 0;
52 // Return the gender of the voice, should be either "male" or "female"
53 // if known, otherwise the empty string.
54 virtual std::string
gender();
56 virtual std::string
error();
57 virtual void clear_error();
58 virtual void set_error(const std::string
& error
);
63 // On some platforms this may be a leaky singleton - do not rely on the
64 // destructor being called! http://crbug.com/122026
65 virtual ~TtsPlatformImpl() {}
69 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImpl
);
72 #endif // CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_