AWS SDK for C++  1.9.41
AWS SDK for C++
TextToSpeechManager.h
Go to the documentation of this file.
1 
6 #pragma once
7 
10 #include <aws/polly/PollyClient.h>
12 #include <functional>
13 #include <memory>
14 #include <mutex>
15 
16 namespace Aws
17 {
18  namespace TextToSpeech
19  {
26  typedef std::function<void(const char*, const Polly::Model::SynthesizeSpeechOutcome&, bool)> SendTextCompletedHandler;
27 
28  typedef std::pair<DeviceInfo, std::shared_ptr<PCMOutputDriver>> OutputDevicePair;
30 
35  static const size_t BUFF_SIZE = 8192;
36 
46  class AWS_TEXT_TO_SPEECH_API TextToSpeechManager : public std::enable_shared_from_this<TextToSpeechManager>
47  {
48  public:
53  static std::shared_ptr<TextToSpeechManager> Create(const std::shared_ptr<Polly::PollyClient>& pollyClient,
54  const std::shared_ptr<PCMOutputDriverFactory>& driverFactory = nullptr);
55 
61 
66  void SendTextToOutputDevice(const char* text, SendTextCompletedHandler callback);
67 
74 
79  void SetActiveDevice(const std::shared_ptr<PCMOutputDriver>&, const DeviceInfo&, const CapabilityInfo&);
80 
86 
90  void SetActiveVoice(const Aws::String& voice);
91 
92  private:
93  TextToSpeechManager(const std::shared_ptr<Polly::PollyClient>& pollyClient,
94  const std::shared_ptr<PCMOutputDriverFactory>& driverFactory);
95 
96  void OnPollySynthSpeechOutcomeRecieved(const Polly::PollyClient*, const Polly::Model::SynthesizeSpeechRequest&,
97  const Polly::Model::SynthesizeSpeechOutcome&, const std::shared_ptr<const Aws::Client::AsyncCallerContext>&) const;
98 
99  Polly::PollyClient* m_pollyClient;
100  std::shared_ptr<PCMOutputDriver> m_activeDriver;
102  std::atomic<Polly::Model::VoiceId> m_activeVoice;
103  CapabilityInfo m_selectedCaps;
104  mutable std::mutex m_driverLock;
105  };
106  }
107 }
Aws::TextToSpeech::TextToSpeechManager::operator=
TextToSpeechManager & operator=(TextToSpeechManager &&)=delete
Aws::TextToSpeech::BUFF_SIZE
static const size_t BUFF_SIZE
Definition: TextToSpeechManager.h:35
Aws::TextToSpeech::TextToSpeechManager::Create
static std::shared_ptr< TextToSpeechManager > Create(const std::shared_ptr< Polly::PollyClient > &pollyClient, const std::shared_ptr< PCMOutputDriverFactory > &driverFactory=nullptr)
Aws::Polly::PollyClient
Definition: PollyClient.h:113
Aws::Vector
std::vector< T, Aws::Allocator< T > > Vector
Definition: AWSVector.h:17
AsyncCallerContext.h
Aws::TextToSpeech::TextToSpeechManager::operator=
TextToSpeechManager & operator=(const TextToSpeechManager &)=delete
Aws::TextToSpeech::TextToSpeechManager::TextToSpeechManager
TextToSpeechManager(const TextToSpeechManager &)=delete
Aws::TextToSpeech::TextToSpeechManager::TextToSpeechManager
TextToSpeechManager(TextToSpeechManager &&)=delete
Aws::TextToSpeech::OutputDevicePair
std::pair< DeviceInfo, std::shared_ptr< PCMOutputDriver > > OutputDevicePair
Definition: TextToSpeechManager.h:28
Aws::TextToSpeech::TextToSpeechManager
Definition: TextToSpeechManager.h:47
Aws::TextToSpeech::OutputDeviceList
Aws::Vector< OutputDevicePair > OutputDeviceList
Definition: TextToSpeechManager.h:29
Aws::TextToSpeech::TextToSpeechManager::SendTextToOutputDevice
void SendTextToOutputDevice(const char *text, SendTextCompletedHandler callback)
Aws::TextToSpeech::TextToSpeechManager::SetActiveVoice
void SetActiveVoice(const Aws::String &voice)
TextToSpeech_EXPORTS.h
Aws::TextToSpeech::TextToSpeechManager::SetActiveDevice
void SetActiveDevice(const std::shared_ptr< PCMOutputDriver > &, const DeviceInfo &, const CapabilityInfo &)
PollyClient.h
Aws::TextToSpeech::TextToSpeechManager::ListAvailableVoices
Aws::Vector< std::pair< Aws::String, Aws::String > > ListAvailableVoices() const
Aws::TextToSpeech::TextToSpeechManager::EnumerateDevices
OutputDeviceList EnumerateDevices() const
AWS_TEXT_TO_SPEECH_API
#define AWS_TEXT_TO_SPEECH_API
Definition: TextToSpeech_EXPORTS.h:27
PCMOutputDriver.h
Aws
Definition: AccessManagementClient.h:15
Aws::Utils::Outcome
Definition: Outcome.h:26
Aws::String
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
Aws::Polly::Model::SynthesizeSpeechRequest
Definition: SynthesizeSpeechRequest.h:29
Aws::TextToSpeech::TextToSpeechManager::~TextToSpeechManager
~TextToSpeechManager()
Aws::TextToSpeech::CapabilityInfo
Definition: PCMOutputDriver.h:24
Aws::TextToSpeech::DeviceInfo
Definition: PCMOutputDriver.h:33
Aws::TextToSpeech::SendTextCompletedHandler
std::function< void(const char *, const Polly::Model::SynthesizeSpeechOutcome &, bool)> SendTextCompletedHandler
Definition: TextToSpeechManager.h:26