AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
TextToSpeechManager.h
1
6#pragma once
7
8#include <aws/text-to-speech/TextToSpeech_EXPORTS.h>
9#include <aws/text-to-speech/PCMOutputDriver.h>
10#include <aws/polly/PollyClient.h>
11#include <aws/core/client/AsyncCallerContext.h>
12#include <functional>
13#include <memory>
14#include <mutex>
15
16namespace 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 OnPollySynthSpeechOutcomeReceived(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}
TextToSpeechManager & operator=(TextToSpeechManager &&)=delete
void SetActiveDevice(const std::shared_ptr< PCMOutputDriver > &, const DeviceInfo &, const CapabilityInfo &)
TextToSpeechManager(const TextToSpeechManager &)=delete
OutputDeviceList EnumerateDevices() const
TextToSpeechManager & operator=(const TextToSpeechManager &)=delete
void SendTextToOutputDevice(const char *text, SendTextCompletedHandler callback)
Aws::Vector< std::pair< Aws::String, Aws::String > > ListAvailableVoices() const
TextToSpeechManager(TextToSpeechManager &&)=delete
void SetActiveVoice(const Aws::String &voice)
static std::shared_ptr< TextToSpeechManager > Create(const std::shared_ptr< Polly::PollyClient > &pollyClient, const std::shared_ptr< PCMOutputDriverFactory > &driverFactory=nullptr)
Aws::Vector< OutputDevicePair > OutputDeviceList
std::function< void(const char *, const Polly::Model::SynthesizeSpeechOutcome &, bool)> SendTextCompletedHandler
std::pair< DeviceInfo, std::shared_ptr< PCMOutputDriver > > OutputDevicePair
static const size_t BUFF_SIZE
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
std::vector< T, Aws::Allocator< T > > Vector