vsdk 11.0.1
Loading...
Searching...
No Matches
Vsdk::Tts::Channelabstract

Can perform voice synthesis. More...

#include <Channel.hpp>

Inheritance diagram for Vsdk::Tts::Channel:
Vsdk::Audio::ProducerModule

Public Member Functions

 Channel (Channel const &) noexcept=delete
 Channel (Channel &&) noexcept=default
Channeloperator= (Channel const &) noexcept=delete
Channeloperator= (Channel &&) noexcept=default
virtual ~Channel () noexcept=default
auto name () const -> std::string const &
 Name of this particular Channel instance.
auto currentVoice () const -> std::string const &
 Name of the currently activated voice, if any.
bool nativeEventsEnabled () const
 Tells whether native events can be received in the events callback (false by default)
virtual int sampleRate () const =0
 The sample rate used during synthesis operations in Hertz.
virtual int channelCount () const =0
 The channel count used during synthesis operations.
void setCurrentVoice (std::string const &voice)
 Activates a voice for the all future synthesis operations.
void setNativeEventsEnabled (bool enabled)
 Sets whether to receive native events in the events callback.
bool synthesizeFromText (std::string text)
 Prepares the next synthesis from a text string (either raw or containing SSML)
bool synthesizeFromFile (std::string const &path)
 Prepares the next synthesis from a file (containing either raw text or SSML).
Public Member Functions inherited from Vsdk::Audio::ProducerModule
 ProducerModule ()
 ProducerModule (ProducerModule &&)
ProducerModuleoperator= (ProducerModule &&)
virtual ~ProducerModule ()=0
 ProducerModule (ProducerModule const &)=delete
ProducerModuleoperator= (ProducerModule const &)=delete
auto subscribeFirst (AudioCallback c) -> Iterator
 Subscribes as first in the list of audio buffer receivers for this producer.
auto subscribeLast (AudioCallback c) -> Iterator
 Subscribes as last in the list of audio buffer receivers for this producer.
void unsubscribe (Iterator it) noexcept
 Unsubscribes from this producer audio buffer dispatch list.
auto state () const -> State
bool isOpened () const
bool isRunning () const
bool isStarted () const
bool isPaused () const
bool isIdle () const
bool isClosed () const
void open ()
 Attempts to open the underlying resource(s) of the producer.
void run ()
void start ()
void pause ()
 Attempts to pause a started producer.
void resume ()
 Attempts to resume a paused producer.
void stop ()
 Attempts to stop a started producer.
void close ()
void setStateChangedCallback (StateChangedCallback c)

Protected Member Functions

 Channel (std::shared_ptr< Engine > engine, std::string name) noexcept
virtual void setCurrentVoiceImpl (std::string const &voice)=0
virtual void synthesize (std::string const &text, bool async)=0
void runImpl () override
void startImpl () override
void dispatchEvent (Event event)
void dispatchError (Error error)
Protected Member Functions inherited from Vsdk::Audio::ProducerModule
virtual void openImpl ()
virtual void pauseImpl ()
virtual void resumeImpl ()
virtual void stopImpl ()
virtual void closeImpl ()
void setState (State s)
void dispatchBuffer (Buffer buffer, bool last)
template<typename T>
void dispatchAudio (T &&data, int sampleRate, int channelCount, bool isLast)

Additional Inherited Members

Public Types inherited from Vsdk::Audio::ProducerModule
enum class  State {
  Closed , Opened , Running , Started ,
  Paused , Idle
}
using StateChangedCallback = std::function<void(State)>
using Iterator = Vsdk::Utils::Iterator<decltype(_subscribers)>
 Iterator pointing to a subscriber of this producer.

Detailed Description

Can perform voice synthesis.

Constructor & Destructor Documentation

◆ Channel() [1/3]

Channel::Channel ( std::shared_ptr< Engine > engine,
std::string name )
protectednoexcept

◆ Channel() [2/3]

Vsdk::Tts::Channel::Channel ( Channel const & )
deletenoexcept

◆ Channel() [3/3]

Vsdk::Tts::Channel::Channel ( Channel && )
defaultnoexcept

◆ ~Channel()

virtual Vsdk::Tts::Channel::~Channel ( )
virtualdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

Channel & Vsdk::Tts::Channel::operator= ( Channel const & )
deletenoexcept

◆ operator=() [2/2]

Channel & Vsdk::Tts::Channel::operator= ( Channel && )
defaultnoexcept

◆ name()

auto Channel::name ( ) const -> std::string const &

Name of this particular Channel instance.

◆ currentVoice()

auto Channel::currentVoice ( ) const -> std::string const &

Name of the currently activated voice, if any.

Returns
Empty string if no voice has been successfully activated yet

◆ nativeEventsEnabled()

bool Channel::nativeEventsEnabled ( ) const

Tells whether native events can be received in the events callback (false by default)

◆ sampleRate()

virtual int Vsdk::Tts::Channel::sampleRate ( ) const
pure virtual

The sample rate used during synthesis operations in Hertz.

◆ channelCount()

virtual int Vsdk::Tts::Channel::channelCount ( ) const
pure virtual

The channel count used during synthesis operations.

◆ setCurrentVoice()

void Channel::setCurrentVoice ( std::string const & voice)

Activates a voice for the all future synthesis operations.

Exceptions
Vsdk::Exceptionif the engine failed to activate the requested voice

◆ setNativeEventsEnabled()

void Channel::setNativeEventsEnabled ( bool enabled)

Sets whether to receive native events in the events callback.

◆ synthesizeFromText()

bool Channel::synthesizeFromText ( std::string text)

Prepares the next synthesis from a text string (either raw or containing SSML)

Note
If the channel is already started and a voice has been set then the synthesis starts immediately. If it is not started, then a call to start() or run() will start the synthesis
Exceptions
Vsdk::Exceptionif text is empty or if an attempt to synthesize failed
Returns
true if a synthesis started right away, else false

◆ synthesizeFromFile()

bool Channel::synthesizeFromFile ( std::string const & path)

Prepares the next synthesis from a file (containing either raw text or SSML).

The file is read right away and its content is stored as preparation for the next synthesis.

Note
If the channel is already started and a voice has been set then the synthesis starts immediately. If it is not started, then a call to start() or run() will start the synthesis
Exceptions
Vsdk::Exceptionif file is not a valid file path, if contained text is empty or if an attempt to synthesize failed
Returns
true if a synthesis started right away, else false

◆ setCurrentVoiceImpl()

virtual void Vsdk::Tts::Channel::setCurrentVoiceImpl ( std::string const & voice)
protectedpure virtual

◆ synthesize()

virtual void Vsdk::Tts::Channel::synthesize ( std::string const & text,
bool async )
protectedpure virtual

◆ runImpl()

void Channel::runImpl ( )
overrideprotectedvirtual

Reimplemented from Vsdk::Audio::ProducerModule.

◆ startImpl()

void Channel::startImpl ( )
overrideprotectedvirtual

Reimplemented from Vsdk::Audio::ProducerModule.

◆ dispatchEvent()

void Channel::dispatchEvent ( Event event)
protected

◆ dispatchError()

void Channel::dispatchError ( Error error)
protected