BogaNet 1.4.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Properties | Events | List of all members
BogaNet.TTS.Speaker Class Reference

Main component for TTS-operations. More...

Inheritance diagram for BogaNet.TTS.Speaker:
BogaNet.Util.Singleton< Speaker > BogaNet.TTS.Provider.IVoiceProvider

Public Member Functions

float ApproximateSpeechLength (string text, float rate=1f, float wordsPerMinute=175f, float timeFactor=0.9f)
 Approximates the speech length in seconds of a given text and rate. NOTE: This method does not provide an exact value; +/- 15% is "normal"!
 
bool IsVoiceForGenderAvailable (Gender gender, string culture="")
 Is a voice available for a given gender and optional culture from the current TTS-system?
 
bool IsVoiceForGenderAvailable (Gender gender, CultureInfo culture)
 Is a voice available for a given gender and language from the current TTS-system?
 
List< VoiceVoicesForGender (Gender gender, string culture="", bool isFuzzy=false)
 Get all available voices for a given gender and optional culture from the current TTS-system.
 
List< VoiceVoicesForGender (Gender gender, CultureInfo culture, bool isFuzzy=false)
 Get all available voices for a given gender and language from the current TTS-system.
 
VoiceVoiceForGender (Gender gender, string culture="", int index=0, string fallbackCulture="en", bool isFuzzy=false)
 Get a voice from for a given gender, optional culture and optional index from the current TTS-system.
 
VoiceVoiceForGender (Gender gender, CultureInfo culture, int index=0, bool isFuzzy=false)
 Get a voice from for a given gender, language and index from the current TTS-system.
 
bool IsVoiceForCultureAvailable (string culture)
 Is a voice available for a given culture from the current TTS-system?
 
bool IsVoiceForLanguageAvailable (CultureInfo culture)
 Is a voice available for a given language from the current TTS-system?
 
List< VoiceVoicesForCulture (string culture, bool isFuzzy=false)
 Get all available voices for a given culture from the current TTS-system.
 
List< VoiceVoicesForLanguage (CultureInfo culture, bool isFuzzy=false)
 Get all available voices for a given language from the current TTS-system.
 
VoiceVoiceForCulture (string culture, int index=0, string fallbackCulture="en", bool isFuzzy=false)
 Get a voice from for a given culture and optional index from the current TTS-system.
 
VoiceVoiceForLanguage (CultureInfo culture, int index=0, bool isFuzzy=false)
 Get a voice from for a given language and optional index from the current TTS-system.
 
bool IsVoiceForNameAvailable (string _name, bool isExact=false)
 Is a voice available for a given name from the current TTS-system?
 
VoiceVoiceForName (string _name, bool isExact=false)
 Get a voice for a given name from the current TTS-system.
 
List< VoiceGetVoices ()
 Get all available voices from the current TTS-provider as a list.
 
async Task< List< Voice > > GetVoicesAsync ()
 Get all available voices from the current TTS-provider as a list asynchronously.
 
void Silence ()
 Silence all active TTS speeches.
 
bool Speak (string text, Voice? voice=null, float rate=1, float pitch=1, float volume=1, bool forceSSML=true, bool useThreaded=false)
 The current provider speaks a text with a given voice.
 
async Task< bool > SpeakAsync (string text, Voice? voice=null, float rate=1, float pitch=1, float volume=1, bool forceSSML=true)
 The current provider speaks a text with a given voice asynchronously.
 
- Public Member Functions inherited from BogaNet.TTS.Provider.IVoiceProvider
delegate void VoicesLoaded (List< Voice > voices)
 Delegate for the load status of the voices.
 
delegate void SpeakStarted (string text)
 Delegate for the speak status.
 
delegate void SpeakCompleted (string text)
 Delegate for the speak status.
 

Protected Member Functions

 Speaker ()
 

Properties

IVoiceProviderCustomVoiceProvider [get, set]
 Custom voice provider.
 
bool UseESpeak [get, set]
 Enable or disable eSpeak for standalone platforms.
 
bool IsTTSAvailable [get]
 Checks if TTS is available on this system.
 
List< VoiceVoices [get]
 Get all available voices from the current TTS-provider and fills it into a given list.
 
int MaxTextLength [get]
 Maximal length of the speech text (in characters).
 
bool IsPlatformSupported [get]
 Indicates if this provider is supporting the current platform.
 
bool IsSSMLSupported [get]
 Indicates if this provider is supporting SSML.
 
List< string > Cultures [get]
 Get all available cultures from the current provider (ISO 639-1).
 
bool IsReady [get]
 Is the provider ready to use?
 
bool IsSpeaking [get]
 Is the provider currently speaking?
 
string ESpeakApplication [get, set]
 eSpeak application name/path.
 
string ESpeakDataPath [get, set]
 eSpeak application data path.
 
ESpeakModifiers ESpeakModifier [get, set]
 Active modifier for all eSpeak voices.
 
ESpeakModifiers ESpeakFemaleModifier [get, set]
 Female modifier for female eSpeak voices.
 
- Properties inherited from BogaNet.Util.Singleton< Speaker >
static T Instance [get]
 
- Properties inherited from BogaNet.TTS.Provider.IVoiceProvider

Events

IVoiceProvider.? VoicesLoaded OnVoicesLoaded
 
IVoiceProvider.? SpeakStarted OnSpeakStarted
 
IVoiceProvider.? SpeakCompleted OnSpeakCompleted
 
- Events inherited from BogaNet.TTS.Provider.IVoiceProvider
VoicesLoaded OnVoicesLoaded
 Event triggered whenever the voices are loaded.
 
SpeakStarted OnSpeakStarted
 Event triggered whenever a speech is started.
 
SpeakCompleted OnSpeakCompleted
 Event triggered whenever a speech is completed.
 

Detailed Description

Main component for TTS-operations.

Constructor & Destructor Documentation

◆ Speaker()

BogaNet.TTS.Speaker.Speaker ( )
protected

Member Function Documentation

◆ ApproximateSpeechLength()

float BogaNet.TTS.Speaker.ApproximateSpeechLength ( string text,
float rate = 1f,
float wordsPerMinute = 175f,
float timeFactor = 0::9f )

Approximates the speech length in seconds of a given text and rate. NOTE: This method does not provide an exact value; +/- 15% is "normal"!

Parameters
textText for the length approximation.
rateSpeech rate of the speaker in percent for the length approximation (1 = 100%, default: 1, optional).
wordsPerMinuteWords per minute (default: 175, optional).
timeFactorTime factor for the calculated value (default: 0.9, optional).
Returns
Approximated speech length in seconds of the given text and rate.

◆ GetVoices()

List< Voice > BogaNet.TTS.Speaker.GetVoices ( )

Get all available voices from the current TTS-provider as a list.

Returns
All available voices (alphabetically ordered by 'Name') as a list.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ GetVoicesAsync()

async Task< List< Voice > > BogaNet.TTS.Speaker.GetVoicesAsync ( )

Get all available voices from the current TTS-provider as a list asynchronously.

Returns
All available voices (alphabetically ordered by 'Name') as a list.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ IsVoiceForCultureAvailable()

bool BogaNet.TTS.Speaker.IsVoiceForCultureAvailable ( string culture)

Is a voice available for a given culture from the current TTS-system?

Parameters
cultureCulture of the voice (e.g. "en")
Returns
True if a voice is available for a given culture.

◆ IsVoiceForGenderAvailable() [1/2]

bool BogaNet.TTS.Speaker.IsVoiceForGenderAvailable ( Gender gender,
CultureInfo culture )

Is a voice available for a given gender and language from the current TTS-system?

Parameters
genderGender of the voice
cultureCulture of the voice
Returns
True if a voice is available for a given gender and language.

◆ IsVoiceForGenderAvailable() [2/2]

bool BogaNet.TTS.Speaker.IsVoiceForGenderAvailable ( Gender gender,
string culture = "" )

Is a voice available for a given gender and optional culture from the current TTS-system?

Parameters
genderGender of the voice
cultureCulture of the voice (e.g. "en", optional)
Returns
True if a voice is available for a given gender and culture.

◆ IsVoiceForLanguageAvailable()

bool BogaNet.TTS.Speaker.IsVoiceForLanguageAvailable ( CultureInfo culture)

Is a voice available for a given language from the current TTS-system?

Parameters
cultureCulture of the voice
Returns
True if a voice is available for a given language.

◆ IsVoiceForNameAvailable()

bool BogaNet.TTS.Speaker.IsVoiceForNameAvailable ( string _name,
bool isExact = false )

Is a voice available for a given name from the current TTS-system?

Parameters
_nameName of the voice (e.g. "Alex")
isExactExact match for the voice name (default: false, optional)
Returns
True if a voice is available for a given name.

◆ Silence()

void BogaNet.TTS.Speaker.Silence ( )

Silence all active TTS speeches.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ Speak()

bool BogaNet.TTS.Speaker.Speak ( string text,
Voice? voice = null,
float rate = 1,
float pitch = 1,
float volume = 1,
bool forceSSML = true,
bool useThreads = false )

The current provider speaks a text with a given voice.

Parameters
textText to speak.
voiceVoice to speak (optional).
rateSpeech rate of the speaker in percent (1 = 100%, values: 0.01-3, default: 1, optional).
pitchPitch of the speech in percent (1 = 100%, values: 0-2, default: 1, optional).
volumeVolume of the speaker in percent (1 = 100%, values: 0.01-1, default: 1, optional).
forceSSMLForce SSML on supported platforms (default: true, optional).
useThreadsAllows to run every Speak-call on a separate thread (default: false, optional).
Returns
True if the speech was successful

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ SpeakAsync()

async Task< bool > BogaNet.TTS.Speaker.SpeakAsync ( string text,
Voice? voice = null,
float rate = 1,
float pitch = 1,
float volume = 1,
bool forceSSML = true )

The current provider speaks a text with a given voice asynchronously.

Parameters
textText to speak.
voiceVoice to speak (optional).
rateSpeech rate of the speaker in percent (1 = 100%, values: 0.01-3, default: 1, optional).
pitchPitch of the speech in percent (1 = 100%, values: 0-2, default: 1, optional).
volumeVolume of the speaker in percent (1 = 100%, values: 0.01-1, default: 1, optional).
forceSSMLForce SSML on supported platforms (default: true, optional).
Returns
True if the speech was successful

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ VoiceForCulture()

Voice? BogaNet.TTS.Speaker.VoiceForCulture ( string culture,
int index = 0,
string fallbackCulture = "en",
bool isFuzzy = false )

Get a voice from for a given culture and optional index from the current TTS-system.

Parameters
cultureCulture of the voice (e.g. "en")
indexIndex of the voice (default: 0, optional)
fallbackCultureFallback culture of the voice (default "en", optional)
isFuzzyAlways returns voices if there is no match with the culture (default: false, optional)
Returns
Voice for the given culture and index.

◆ VoiceForGender() [1/2]

Voice? BogaNet.TTS.Speaker.VoiceForGender ( Gender gender,
CultureInfo culture,
int index = 0,
bool isFuzzy = false )

Get a voice from for a given gender, language and index from the current TTS-system.

Parameters
genderGender of the voice
cultureCulture of the voice
indexIndex of the voice (default: 0, optional)
isFuzzyAlways returns voices if there is no match with the gender and/or language (default: false, optional)
Returns
Voice for the given gender, language and index.

◆ VoiceForGender() [2/2]

Voice? BogaNet.TTS.Speaker.VoiceForGender ( Gender gender,
string culture = "",
int index = 0,
string fallbackCulture = "en",
bool isFuzzy = false )

Get a voice from for a given gender, optional culture and optional index from the current TTS-system.

Parameters
genderGender of the voice
cultureCulture of the voice (e.g. "en", optional)
indexIndex of the voice (default: 0, optional)
fallbackCultureFallback culture of the voice (default "en", optional)
isFuzzyAlways returns voices if there is no match with the gender and/or culture (default: false, optional)
Returns
Voice for the given gender, culture and index.

◆ VoiceForLanguage()

Voice? BogaNet.TTS.Speaker.VoiceForLanguage ( CultureInfo culture,
int index = 0,
bool isFuzzy = false )

Get a voice from for a given language and optional index from the current TTS-system.

Parameters
cultureCulture of the voice
indexIndex of the voice (default: 0, optional)
isFuzzyAlways returns voices if there is no match with the language (default: false, optional)
Returns
Voice for the given language and index.

◆ VoiceForName()

Voice? BogaNet.TTS.Speaker.VoiceForName ( string _name,
bool isExact = false )

Get a voice for a given name from the current TTS-system.

Parameters
_nameName of the voice (e.g. "Alex")
isExactExact match for the voice name (default: false, optional)
Returns
Voice for the given name or null if not found.

◆ VoicesForCulture()

List< Voice > BogaNet.TTS.Speaker.VoicesForCulture ( string culture,
bool isFuzzy = false )

Get all available voices for a given culture from the current TTS-system.

Parameters
cultureCulture of the voice (e.g. "en")
isFuzzyAlways returns voices if there is no match with the culture (default: false, optional)
Returns
All available voices (alphabetically ordered by 'Name') for a given culture as a list.

◆ VoicesForGender() [1/2]

List< Voice > BogaNet.TTS.Speaker.VoicesForGender ( Gender gender,
CultureInfo culture,
bool isFuzzy = false )

Get all available voices for a given gender and language from the current TTS-system.

Parameters
genderGender of the voice
cultureCulture of the voice
isFuzzyAlways returns voices if there is no match with the gender and/or language (default: false, optional)
Returns
All available voices (alphabetically ordered by 'Name') for a given gender and language as a list.

◆ VoicesForGender() [2/2]

List< Voice > BogaNet.TTS.Speaker.VoicesForGender ( Gender gender,
string culture = "",
bool isFuzzy = false )

Get all available voices for a given gender and optional culture from the current TTS-system.

Parameters
genderGender of the voice
cultureCulture of the voice (e.g. "en", optional)
isFuzzyAlways returns voices if there is no match with the gender and/or culture (default: false, optional)
Returns
All available voices (alphabetically ordered by 'Name') for a given gender and culture as a list.

◆ VoicesForLanguage()

List< Voice > BogaNet.TTS.Speaker.VoicesForLanguage ( CultureInfo culture,
bool isFuzzy = false )

Get all available voices for a given language from the current TTS-system.

Parameters
cultureCulture of the voice
isFuzzyAlways returns voices if there is no match with the language (default: false, optional)
Returns
All available voices (alphabetically ordered by 'Name') for a given language as a list.

Property Documentation

◆ Cultures

List<string> BogaNet.TTS.Speaker.Cultures
get

Get all available cultures from the current provider (ISO 639-1).

Returns
All available cultures (alphabetically ordered by 'Culture') as a list.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ CustomVoiceProvider

IVoiceProvider? BogaNet.TTS.Speaker.CustomVoiceProvider
getset

Custom voice provider.

◆ ESpeakApplication

string BogaNet.TTS.Speaker.ESpeakApplication
getset

eSpeak application name/path.

◆ ESpeakDataPath

string BogaNet.TTS.Speaker.ESpeakDataPath
getset

eSpeak application data path.

◆ ESpeakFemaleModifier

ESpeakModifiers BogaNet.TTS.Speaker.ESpeakFemaleModifier
getset

Female modifier for female eSpeak voices.

◆ ESpeakModifier

ESpeakModifiers BogaNet.TTS.Speaker.ESpeakModifier
getset

Active modifier for all eSpeak voices.

◆ IsPlatformSupported

bool BogaNet.TTS.Speaker.IsPlatformSupported
get

Indicates if this provider is supporting the current platform.

Returns
True if this provider supports current platform.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ IsReady

bool BogaNet.TTS.Speaker.IsReady
get

Is the provider ready to use?

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ IsSpeaking

bool BogaNet.TTS.Speaker.IsSpeaking
get

Is the provider currently speaking?

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ IsSSMLSupported

bool BogaNet.TTS.Speaker.IsSSMLSupported
get

Indicates if this provider is supporting SSML.

Returns
True if this provider supports SSML.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ IsTTSAvailable

bool BogaNet.TTS.Speaker.IsTTSAvailable
get

Checks if TTS is available on this system.

Returns
True if TTS is available on this system.

◆ MaxTextLength

int BogaNet.TTS.Speaker.MaxTextLength
get

Maximal length of the speech text (in characters).

Returns
The maximal length of the speech text.

Implements BogaNet.TTS.Provider.IVoiceProvider.

◆ UseESpeak

bool BogaNet.TTS.Speaker.UseESpeak
getset

Enable or disable eSpeak for standalone platforms.

◆ Voices

List<Voice> BogaNet.TTS.Speaker.Voices
get

Get all available voices from the current TTS-provider and fills it into a given list.

Returns
All available voices (alphabetically ordered by 'Name') as a list.

Implements BogaNet.TTS.Provider.IVoiceProvider.

Event Documentation

◆ OnSpeakCompleted

IVoiceProvider.? SpeakCompleted BogaNet.TTS.Speaker.OnSpeakCompleted

◆ OnSpeakStarted

IVoiceProvider.? SpeakStarted BogaNet.TTS.Speaker.OnSpeakStarted

◆ OnVoicesLoaded

IVoiceProvider.? VoicesLoaded BogaNet.TTS.Speaker.OnVoicesLoaded

The documentation for this class was generated from the following file: