Class SttClient

Definition

Namespace:
Tizen.Uix.Stt
Assembly:
Tizen.Uix.Stt.dll

A main function of Speech-To-Text (below STT) API recognizes sound data recorded by users. After choosing a language, the applications will start recording and recognizing. After recording, the applications will receive the recognized result. The STT has a client-server for the service of multi-applications. The STT service always works in the background as a server. If the service is not working, client library will invoke it and the client will communicate with it. The service has engines and a recorder, so that the client does not have the recorder itself. Only the client request commands to the STT service for using STT.

C#
Copy
public class SttClient : IDisposable
Inheritance
object
SttClient
Implements
System.IDisposable

Constructors

View Source

SttClient()

Constructor to create a STT instance.

Declaration
C#
Copy
public SttClient()
Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to operation failed.

System.OutOfMemoryException

This exception can be due to out of memory.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

Properties

View Source

CurrentState

Gets the current STT state.

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

Current state of STT.

View Source

DefaultLanguage

Gets the default language set by the user. The language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code. For example, "ko_KR" for Korean, "en_US" for American English.

Declaration
C#
Copy
public string DefaultLanguage { get; }
Property Value
Type Description
string

Default language in STT.

View Source

Engine

This property can be used to get and set the current engine id.

Declaration
C#
Copy
public string Engine { get; set; }
Property Value
Type Description
string

Current STT engine id.

Exceptions
Type Condition
System.InvalidOperationException

This exceptioncan occur while setting due to the following reasons:

  1. Operation Failed
  2. Invalid State
System.OutOfMemoryException

This exception can be due to out of memory.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

System.ArgumentException

This can happen if improper EngineId is provided while setting the value.

View Source

RecordingVolume

Gets the microphone volume during recording.

Declaration
C#
Copy
public float RecordingVolume { get; }
Property Value
Type Description
float

Recording volume in STT.

Methods

View Source

Cancel()

Cancels processing the recognition and recording asynchronously. This function cancels recording and the engine cancels recognition processing. After successful cancellation, the StateChanged event is invoked, otherwise if an error is occurs, the ErrorOccurred event is invoked.

Declaration
C#
Copy
public void Cancel()
Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
  3. Progress to ready is not finished
  4. Progress to recording is not finished
  5. Progress to processing is not finished
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

Dispose()

Method to release resources.

Declaration
C#
Copy
public void Dispose()
View Source

Dispose(bool)

Method to release resources.

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

The boolean value for destoying stt handle.

View Source

~SttClient()

Destructor to destroy a STT instance.

Declaration
C#
Copy
protected ~SttClient()
View Source

GetDetailedResult()

Retrieves the time stamp of the current recognition result.

Declaration
C#
Copy
public IEnumerable<ResultTime> GetDetailedResult()
Returns
Type Description
System.Collections.Generic.IEnumerable<T><ResultTime>

List of ResultTime.

Remarks

This function should only be called in the RecognitionResult event.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to operation failed.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

GetPrivateData(string)

Gets the private data from the STT engine.

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

The key string.

Returns
Type Description
string

The data corresponding to the key is provided.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to invalid state.

System.NotSupportedException

This exception can be due to STT not supported.

System.TimeoutException

This exception can be due to No Answer from STT Service.

View Source

GetSupportedEngines()

Gets the list of supported engines.

Declaration
C#
Copy
public IEnumerable<SupportedEngine> GetSupportedEngines()
Returns
Type Description
System.Collections.Generic.IEnumerable<T><SupportedEngine>

IEnumerable<SupportedEngine> list of supported engines.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to operation failed.

System.OutOfMemoryException

This exception can be due to out of memory.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

GetSupportedLanguages()

Retrieves all the supported languages of the current engine. The language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code. For example, "ko_KR" for Korean, "en_US" for American English.

Declaration
C#
Copy
public IEnumerable<string> GetSupportedLanguages()
Returns
Type Description
System.Collections.Generic.IEnumerable<T><string>

List of strings for supported languages.

Exceptions
Type Condition
System.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 STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

IsRecognitionTypeSupported(RecognitionType)

Checks whether the recognition type is supported.

Declaration
C#
Copy
public bool IsRecognitionTypeSupported(RecognitionType type)
Parameters
Type Name Description
RecognitionType type

RecognitionType value.

Returns
Type Description
bool

Bool value indicating whether the recognition type is supported.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Engine Not Found
  3. Operation Failed
System.NotSupportedException

This exception can be due to STT not supported.

View Source

Prepare()

Connects to the STT service asynchronously.

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

This exception can be due to invalid state.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

SetCredential(string)

Sets the application credential.

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

The credential string.

Exceptions
Type Condition
System.InvalidOperationException

This exceptioncan be due to the following reasons:

  1. Operation Failed
  2. Invalid State
System.OutOfMemoryException

This exception can be due to out of memory.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

System.ArgumentException

This can happen if Improper value is provided while setting the value.

View Source

SetPrivateData(string, string)

Sets the private data to the STT engine.

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

The key string.

string data

The data string.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to invalid state.

System.NotSupportedException

This exception can be due to STT not supported.

System.TimeoutException

This exception can be due to No Answer from STT Service.

System.ArgumentException

This can happen if Improper value is provided while setting the value.

View Source

SetSilenceDetection(SilenceDetection)

Sets the silence detection.

Declaration
C#
Copy
public void SetSilenceDetection(SilenceDetection type)
Parameters
Type Name Description
SilenceDetection type

SilenceDetection value.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Not supported feature of current engine
  3. Operation Failed
System.NotSupportedException

This exception can be due to STT not supported.

View Source

SetStartSound(string)

Sets the sound to start recording. Sound file type should be .wav type.

Declaration
C#
Copy
public void SetStartSound(string filePath)
Parameters
Type Name Description
string filePath

File path for the sound.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

System.ArgumentException

If an Invalid Parameter is provided.

View Source

SetStopSound(string)

Sets the sound to stop recording. Sound file type should be .wav type.

Declaration
C#
Copy
public void SetStopSound(string filePath)
Parameters
Type Name Description
string filePath

File Path for the sound.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

System.ArgumentException

This exception can be due to Invalid Parameter.

View Source

Start(string, RecognitionType)

Starts the recording and recognition asynchronously. This function starts recording in the STT service and sends the recording data to the engine. This work continues until stop, cancel, or silence is detected by engine.

Declaration
C#
Copy
public void Start(string language, RecognitionType type)
Parameters
Type Name Description
string language

The language selected.

RecognitionType type

The type for recognition.

Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
  3. Recorder Busy
  4. Progress to recording is not finished
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

System.ArgumentException

This exception can be due to an invalid language.

View Source

Stop()

Finishes the recording and starts recognition processing in the engine asynchronously.

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

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
  3. Progress to ready is not finished
  4. Progress to recording is not finished
  5. Progress to processing is not finished
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

Unprepare()

Disconnects from the STT service.

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

This exception can be due to invalid state.

System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

UnsetStartSound()

Unsets the sound to start recording.

Declaration
C#
Copy
public void UnsetStartSound()
Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

This exception can be due to permission denied.

View Source

UnsetStopSound()

Unsets the sound to stop recording.

Declaration
C#
Copy
public void UnsetStopSound()
Exceptions
Type Condition
System.InvalidOperationException

This exception can be due to the following reasons:

  1. Invalid State
  2. Operation Failed
System.NotSupportedException

This exception can be due to STT not supported.

System.UnauthorizedAccessException

his exception can be due to permission denied.

Events

View Source

DefaultLanguageChanged

Event to be invoked when the default language changes.

Declaration
C#
Copy
public event EventHandler<DefaultLanguageChangedEventArgs> DefaultLanguageChanged
Event Type
Type Description
System.EventHandler<TEventArgs><DefaultLanguageChangedEventArgs>
View Source

EngineChanged

Event to be invoked to detect the engine change.

Declaration
C#
Copy
public event EventHandler<EngineChangedEventArgs> EngineChanged
Event Type
Type Description
System.EventHandler<TEventArgs><EngineChangedEventArgs>
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<TEventArgs><ErrorOccurredEventArgs>
View Source

RecognitionResult

Event to be invoked when the recognition is done.

Declaration
C#
Copy
public event EventHandler<RecognitionResultEventArgs> RecognitionResult
Event Type
Type Description
System.EventHandler<TEventArgs><RecognitionResultEventArgs>
View Source

StateChanged

Event to be invoked when the STT state changes.

Declaration
C#
Copy
public event EventHandler<StateChangedEventArgs> StateChanged
Event Type
Type Description
System.EventHandler<TEventArgs><StateChangedEventArgs>

Implements

System.IDisposable