You.i Engine
YiSpeechSynthesizer.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2018. All rights reserved.
2 #ifndef _YI_SPEECH_SYNTHESIZER_H_
3 #define _YI_SPEECH_SYNTHESIZER_H_
4 
5 #include "signal/YiSignal.h"
6 #include "utility/YiString.h"
7 
8 #include <atomic>
9 #include <queue>
10 
24 {
25 public:
26  class Platform;
27 
33  struct ErrorInfo
34  {
36  m_errorText(text) {}
37 
39  };
40 
46  class Utterance
47  {
48  public:
52  Utterance(const CYIString &textToSpeak);
53 
54  virtual ~Utterance();
55 
59  const CYIString &GetText() const;
60 
64  ssize_t GetId() const;
65 
66  private:
67  static std::atomic<ssize_t> s_nLastUsedId;
68 
69  ssize_t m_nId;
70  CYIString m_textToSpeak;
71  };
72 
73  virtual ~CYISpeechSynthesizer();
74 
82  void Speak(const std::shared_ptr<Utterance> &pUtterance, bool bSpeakImmediately = false);
83 
87  void StopSpeaking();
88 
92  bool IsSpeaking() const;
93 
99 
105 
112 
113 private:
114  CYISpeechSynthesizer(std::unique_ptr<Platform> pPlatform);
115 
116  void SpeakNextInQueue(bool bClearCurrentUtterance = false);
117 
118  std::unique_ptr<Platform> m_pSpeechPlatform;
119 
120  std::shared_ptr<Utterance> m_CurrentUtterance;
121  std::queue<std::shared_ptr<Utterance>> m_UtteranceQueue;
122 
123  mutable CYIRecursiveMutex m_UtteranceMutex;
124 };
125 
130 #endif
void Speak(const std::shared_ptr< Utterance > &pUtterance, bool bSpeakImmediately=false)
Provides text-to-speech functionality using the underlying platform&#39;s technology. ...
Definition: YiSpeechSynthesizer.h:23
Provides specific information about an error encountered when sending an CYISpeechSynthesizer::Uttera...
Definition: YiSpeechSynthesizer.h:33
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:35
Definition: YiRecursiveMutex.h:15
CYISignal< const std::shared_ptr< Utterance > &, ErrorInfo > ErrorSpeaking
Definition: YiSpeechSynthesizer.h:111
virtual ~CYISpeechSynthesizer()
bool IsSpeaking() const
CYIString m_errorText
Definition: YiSpeechSynthesizer.h:38
Provides information about a specific phrase of text that can be used to send speech to the audio dev...
Definition: YiSpeechSynthesizer.h:46
CYISignal< const std::shared_ptr< Utterance > & > StartedSpeaking
Definition: YiSpeechSynthesizer.h:98
int ssize_t
Definition: YiPredefWin32.h:133
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:164
ErrorInfo(CYIString text)
Definition: YiSpeechSynthesizer.h:35
CYISignal< const std::shared_ptr< Utterance > &, bool > FinishedSpeaking
Definition: YiSpeechSynthesizer.h:104