OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_ | 5 #ifndef CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_ |
6 #define CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_ | 6 #define CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/speech/tts_controller.h" | 10 #include "chrome/browser/speech/tts_controller.h" |
11 | 11 |
12 // Abstract class that defines the native platform TTS interface, | 12 // Abstract class that defines the native platform TTS interface, |
13 // subclassed by specific implementations on Win, Mac, etc. | 13 // subclassed by specific implementations on Win, Mac, etc. |
14 class TtsPlatformImpl { | 14 class TtsPlatformImpl { |
15 public: | 15 public: |
16 static TtsPlatformImpl* GetInstance(); | 16 static TtsPlatformImpl* GetInstance(); |
17 | 17 |
18 // Returns true if this platform implementation is supported and available. | 18 // Returns true if this platform implementation is supported and available. |
19 virtual bool PlatformImplAvailable() = 0; | 19 virtual bool PlatformImplAvailable() = 0; |
20 | 20 |
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); | |
27 | |
28 // Speak the given utterance with the given parameters if possible, | 21 // Speak the given utterance with the given parameters if possible, |
29 // and return true on success. Utterance will always be nonempty. | 22 // and return true on success. Utterance will always be nonempty. |
30 // If rate, pitch, or volume are -1.0, they will be ignored. | 23 // If rate, pitch, or volume are -1.0, they will be ignored. |
31 // | 24 // |
32 // The TtsController will only try to speak one utterance at | 25 // The TtsController will only try to speak one utterance at |
33 // a time. If it wants to interrupt speech, it will always call Stop | 26 // a time. If it wants to interrupt speech, it will always call Stop |
34 // before speaking again. | 27 // before speaking again. |
35 virtual bool Speak( | 28 virtual bool Speak( |
36 int utterance_id, | 29 int utterance_id, |
37 const std::string& utterance, | 30 const std::string& utterance, |
(...skipping 11 matching lines...) Expand all Loading... |
49 // to |out_voices|. | 42 // to |out_voices|. |
50 virtual void GetVoices(std::vector<VoiceData>* out_voices) = 0; | 43 virtual void GetVoices(std::vector<VoiceData>* out_voices) = 0; |
51 | 44 |
52 // Pause the current utterance, if any, until a call to Resume, | 45 // Pause the current utterance, if any, until a call to Resume, |
53 // Speak, or StopSpeaking. | 46 // Speak, or StopSpeaking. |
54 virtual void Pause() = 0; | 47 virtual void Pause() = 0; |
55 | 48 |
56 // Resume speaking the current utterance, if it was paused. | 49 // Resume speaking the current utterance, if it was paused. |
57 virtual void Resume() = 0; | 50 virtual void Resume() = 0; |
58 | 51 |
| 52 // Allows the platform to monitor speech commands and the voices used |
| 53 // for each one. |
| 54 virtual void WillSpeakUtteranceWithVoice(const Utterance* utterance, |
| 55 const VoiceData& voice_data); |
| 56 |
59 virtual std::string error(); | 57 virtual std::string error(); |
60 virtual void clear_error(); | 58 virtual void clear_error(); |
61 virtual void set_error(const std::string& error); | 59 virtual void set_error(const std::string& error); |
62 | 60 |
63 protected: | 61 protected: |
64 TtsPlatformImpl() {} | 62 TtsPlatformImpl() {} |
65 | 63 |
66 // On some platforms this may be a leaky singleton - do not rely on the | 64 // On some platforms this may be a leaky singleton - do not rely on the |
67 // destructor being called! http://crbug.com/122026 | 65 // destructor being called! http://crbug.com/122026 |
68 virtual ~TtsPlatformImpl() {} | 66 virtual ~TtsPlatformImpl() {} |
69 | 67 |
70 std::string error_; | 68 std::string error_; |
71 | 69 |
72 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImpl); | 70 DISALLOW_COPY_AND_ASSIGN(TtsPlatformImpl); |
73 }; | 71 }; |
74 | 72 |
75 #endif // CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_ | 73 #endif // CHROME_BROWSER_SPEECH_TTS_PLATFORM_H_ |
OLD | NEW |