Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / speech / tts_platform.h
blobc4a29e729651249b90a0512fc9ef11379973c0ea
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_
8 #include <string>
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 {
15 public:
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(
27 content::BrowserContext* browser_context);
29 // Speak the given utterance with the given parameters if possible,
30 // and return true on success. Utterance will always be nonempty.
31 // If rate, pitch, or volume are -1.0, they will be ignored.
33 // The TtsController will only try to speak one utterance at
34 // a time. If it wants to interrupt speech, it will always call Stop
35 // before speaking again.
36 virtual bool Speak(
37 int utterance_id,
38 const std::string& utterance,
39 const std::string& lang,
40 const VoiceData& voice,
41 const UtteranceContinuousParameters& params) = 0;
43 // Stop speaking immediately and return true on success.
44 virtual bool StopSpeaking() = 0;
46 // Returns whether any speech is on going.
47 virtual bool IsSpeaking() = 0;
49 // Append information about voices provided by this platform implementation
50 // to |out_voices|.
51 virtual void GetVoices(std::vector<VoiceData>* out_voices) = 0;
53 // Pause the current utterance, if any, until a call to Resume,
54 // Speak, or StopSpeaking.
55 virtual void Pause() = 0;
57 // Resume speaking the current utterance, if it was paused.
58 virtual void Resume() = 0;
60 // Allows the platform to monitor speech commands and the voices used
61 // for each one.
62 virtual void WillSpeakUtteranceWithVoice(const Utterance* utterance,
63 const VoiceData& voice_data);
65 virtual std::string error();
66 virtual void clear_error();
67 virtual void set_error(const std::string& error);
69 protected:
70 TtsPlatformImpl() {}
72 // On some platforms this may be a leaky singleton - do not rely on the
73 // destructor being called! http://crbug.com/122026
74 virtual ~TtsPlatformImpl() {}
76 std::string error_;
78 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImpl);
81 #endif // CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_