Class TtsClient

Definition

Namespace:
Tizen.Uix.Tts
Assembly:
Tizen.Uix.Tts.dll
API Level:
3

You can use Text-To-Speech (TTS) API's to read sound data transformed by the engine from input texts. Applications can add input-text to queue for reading continuously and control the player that can play, pause, and stop sound data synthesized from text.

C#
Copy
public class TtsClient : IDisposable
Inheritance
TtsClient
Implements
System.IDisposable

Constructors

View Source

TtsClient()

Constructor to create a TTS instance.

Declaration
C#
Copy
public TtsClient()
Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Operation Failed
  2. Engine Not Found
OutOfMemoryException

This exception can be due to out Of memory.

System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis

Properties

View Source

CurrentMode

The TTS Mode can be set using this property.

Declaration
C#
Copy
public Mode CurrentMode { get; set; }
Property Value
Type Description
Mode

The current TTS mode (default, screen-reader, notification).

Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons while setting the value:

  1. Operation Failed
  2. Engine Not Found
OutOfMemoryException

This exception can be due to out Of memory.

System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Precondition: The State should be created.
View Source

CurrentState

Gets the current TTS state.

Declaration
C#
Copy
public State CurrentState { get; }
Property Value
Type Description
State

The current state of TTS.

API Level: 3
View Source

DefaultVoice

Gets the default voice set by the user.

Declaration
C#
Copy
public SupportedVoice DefaultVoice { get; }
Property Value
Type Description
SupportedVoice

The default voice in TTS.

API Level: 3
View Source

MaxTextSize

Gets the maximum byte size for text.

Declaration
C#
Copy
public uint MaxTextSize { get; }
Property Value
Type Description
System.UInt32

The Maximum byte size for text.

API Level: 3
Precondition: The State should be ready.

Methods

View Source

AddText(String, String, Int32, Int32)

Adds a text to the queue.

Declaration
C#
Copy
public int AddText(string text, string language, int voiceType, int speed)
Parameters
Type Name Description
System.String text

An input text based UTF-8.

System.String language

The language selected from the SupportedVoice.Language Property obtained from GetSupportedVoices()(e.g. 'NULL'(Automatic),'en_US').

System.Int32 voiceType

The voice type selected from the SupportedVoice.VoiceType Property obtained from GetSupportedVoices().

System.Int32 speed

A speaking speed (e.g.0 for Auto or the value from SpeedRange Property).

Returns
Type Description
System.Int32

The utterance ID.

Remarks

Locale MUST be set for UTF-8 text validation check.

Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failure
  3. Invalid Voice
System.NotSupportedException

This exception can be due to TTS not supported.

UnauthorizedAccessException

This exception can be due to permission denied.

System.ArgumentException

This exception can be due to improper value provided while setting the value.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be ready or playing or paused.
View Source

Dispose()

Method to release resources.

Declaration
C#
Copy
public void Dispose()
API Level: 3
View Source

Dispose(Boolean)

Method to release resources.

Declaration
C#
Copy
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

The boolean value for destoying tts handle.

API Level: 3
View Source

Finalize()

Destructor to destroy TtsClient handle.

Declaration
C#
Copy
protected void Finalize()
View Source

GetPrivateData(String)

Gets the private data from TTS engine.

Declaration
C#
Copy
public string GetPrivateData(string key)
Parameters
Type Name Description
System.String key

The key string.

Returns
Type Description
System.String

The data corresponding to the provided key.

Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Engine Not found
  3. Operation Failure
System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be ready.
View Source

GetSpeedRange()

Gets the speed range.

Declaration
C#
Copy
public SpeedRange GetSpeedRange()
Returns
Type Description
SpeedRange

The SpeedRange value.

Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failure
System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be created.
View Source

GetSupportedVoices()

Retrieves all supported voices of the current engine.

Declaration
C#
Copy
public IEnumerable<SupportedVoice> GetSupportedVoices()
Returns
Type Description
System.Collections.Generic.IEnumerable<SupportedVoice>

The list of SupportedVoice.

Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Engine Not Found
  2. Operation Failed
System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
View Source

Pause()

Pauses the currently playing utterance.

Declaration
C#
Copy
public void Pause()
Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failure
System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be playing.
Postcondition: If this function succeeds, the TTS state will be Paused.
View Source

Play()

Starts synthesizing voice from the text and plays the synthesized audio data.

Declaration
C#
Copy
public void Play()
Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failure
  3. Out of Network
System.NotSupportedException

This exception can be due to TTS not supported.

UnauthorizedAccessException

This exception can be due to permission denied.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be ready or paused.
Postcondition: If this function succeeds, the TTS state will be playing.
View Source

Prepare()

Connects to the TTS service asynchronously.

Declaration
C#
Copy
public void Prepare()
Exceptions
Type Condition
InvalidOperationException

This exception can be due to an invalid state.

System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The State must be Created.
Postcondition: If this function is successful, the TTS state will be ready. If this function is unsuccessful, ErrorOccurred event will be invoked.
View Source

SetCredential(String)

Sets the application credential.

Declaration
C#
Copy
public void SetCredential(string credential)
Parameters
Type Name Description
System.String credential

. The credential string.

Exceptions
Type Condition
InvalidOperationException

This exception can be due to an invalid state.

System.NotSupportedException

This exception can be due to TTS not supported.

System.ArgumentException

This exception can be due to improper value provided while setting the value.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The State should be created or ready.
View Source

SetPrivateData(String, String)

Sets the private data to tts engine.

Declaration
C#
Copy
public void SetPrivateData(string key, string data)
Parameters
Type Name Description
System.String key

The key string.

System.String data

The data string.

Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Engine Not found
  3. Operation Failure
System.NotSupportedException

This exception can be due to TTS not supported.

System.ArgumentException

This exception can be due to improper value provided while setting the value.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be ready.
View Source

Stop()

Stops playing the utterance and clears the queue.

Declaration
C#
Copy
public void Stop()
Exceptions
Type Condition
InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid Stat
  2. Operation Failure
System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be ready or playing or paused.
Postcondition: If this function succeeds, the TTS state will be ready. This function will remove all text added via AddText() and synthesized sound data.
View Source

Unprepare()

Disconnects from the STT service.

Declaration
C#
Copy
public void Unprepare()
Exceptions
Type Condition
InvalidOperationException

This exception can be due to an invalid state.

System.NotSupportedException

This exception can be due to TTS not supported.

API Level: 3
Feature: http://tizen.org/feature/speech.synthesis
Precondition: The state must be ready.
Postcondition: If this function is successful, the TTS state will be created.

Events

View Source

DefaultVoiceChanged

Event to be invoked when an error occurs.

Declaration
C#
Copy
public event EventHandler<DefaultVoiceChangedEventArgs> DefaultVoiceChanged
Event Type
Type Description
System.EventHandler<DefaultVoiceChangedEventArgs>
API Level: 3
View Source

EngineChanged

Event to be invoked to detect engine change.

Declaration
C#
Copy
public event EventHandler<EngineChangedEventArgs> EngineChanged
Event Type
Type Description
System.EventHandler<EngineChangedEventArgs>
API Level: 3
View Source

ErrorOccurred

Event to be invoked when an error occurs.

Declaration
C#
Copy
public event EventHandler<ErrorOccurredEventArgs> ErrorOccurred
Event Type
Type Description
System.EventHandler<ErrorOccurredEventArgs>
API Level: 4
View Source

StateChanged

Event to be invoked when TTS state changes.

Declaration
C#
Copy
public event EventHandler<StateChangedEventArgs> StateChanged
Event Type
Type Description
System.EventHandler<StateChangedEventArgs>
API Level: 3
View Source

UtteranceCompleted

Event to be invoked when the utterance completes.

Declaration
C#
Copy
public event EventHandler<UtteranceEventArgs> UtteranceCompleted
Event Type
Type Description
System.EventHandler<UtteranceEventArgs>
API Level: 3
View Source

UtteranceStarted

Event to be invoked when the utterance starts.

Declaration
C#
Copy
public event EventHandler<UtteranceEventArgs> UtteranceStarted
Event Type
Type Description
System.EventHandler<UtteranceEventArgs>
API Level: 3

Implements

System.IDisposable