Class Engine

Definition

Namespace:
Tizen.Uix.SttEngine
Assembly:
Tizen.Uix.SttEngine.dll
API Level:
4

This class represents the STT Engine, which has to be inherited to make the engine.

C#
Copy
public abstract class Engine
Inheritance
Engine

Constructors

View Source

Engine()

Public constructor.

Declaration
C#
Copy
public Engine()
API Level: 4
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone

Methods

View Source

Cancel()

Called when the engine service user cancels to recognize the recording data. This callback function is called by the engine service user to cancel to recognize the recording data. Also, when starting the recorder is failed, this function is called.

Declaration
C#
Copy
public abstract Error Cancel()
Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
API Level: 4
View Source

CheckAppAgreed(String, out Boolean)

Called when the engine service user requests for the STT engine to check whether the application agreed the usage of the STT engine. This callback function is called when the engine service user requests for the STT engine to check the application's agreement about using the engine. According to the need, the engine developer can provide some user interfaces to check the agreement.

Declaration
C#
Copy
public abstract Error CheckAppAgreed(string appid, out bool isAgreed)
Parameters
Type Name Description
System.String appid

The Application ID

Boolean isAgreed

A variable for checking whether the application agreed to use the STT engine or not. true to agree, false to disagree.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. NotSupportedFeature
API Level: 4
View Source

Deinitialize()

Called when the engine service user deinitializes the STT engine. This callback function is called by the engine service user to request for the STT engine to be deinitialized.

Declaration
C#
Copy
public abstract Error Deinitialize()
Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
API Level: 4
View Source

EngineMain(Int32, String[])

Main function for the Speech-To-Text (STT) engine. This function is the main function for operating the STT engine.

Declaration
C#
Copy
public void EngineMain(int argc, string[] argv)
Parameters
Type Name Description
System.Int32 argc

The number of arguments.

System.String[] argv

The arguments array.

Remarks

ServiceAppMain should be used for working the engine after this function.

Exceptions
Type Condition
UnauthorizedAccessException

Thrown in case of permission denied.

System.NotSupportedException

Thrown in case of not supported.

InvalidOperationException

Thrown in case of an operation failure.

API Level: 4
Privilege Level: public
Privilege: http://tizen.org/privilege/recorder
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone
View Source

ForEachResultTime(IntPtr, Engine.ResultTime, IntPtr)

Called when the engine service user gets the result time information(stamp).

Declaration
C#
Copy
public abstract Error ForEachResultTime(IntPtr timeInfo, Engine.ResultTime callback, IntPtr userData)
Parameters
Type Name Description
System.IntPtr timeInfo

The time information.

Engine.ResultTime callback

The callback function.

System.IntPtr userData

The user data, which must be passed to the callback function ResultTime.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. InvalidParameter
Remarks

In this function, the engine service user's callback delegate 'ResultTime' is invoked repeatedly for sending the time information to the engine service user and user_data must be transferred to 'ResultTime'. If 'ResultTime' returns false, it should be stopped to call 'ResultTime'. timeInfo is transferred from SendResult. The type of timeInfo is up to the STT engine developer.

API Level: 4
View Source

ForEachSupportedLanguages(Engine.SupportedLanguages, IntPtr)

Called when the engine service user gets the whole supported language list.

Declaration
C#
Copy
public abstract Error ForEachSupportedLanguages(Engine.SupportedLanguages callback, IntPtr userData)
Parameters
Type Name Description
Engine.SupportedLanguages callback

The callback function,

System.IntPtr userData

The user data, which must be passed to the callback delegate 'SupportedLanguages'.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. InvalidParameter
Remarks

In this function, the engine service user's callback function 'SupportedLanguages' is invoked repeatedly for getting all the supported languages and user_data must be transferred to 'SupportedLanguages'. If 'SupportedLanguages' returns false, it should be stopped to call 'SupportedLanguages'.

API Level: 4
View Source

GetInformation(out String, out String, out String, out Boolean)

Called when the engine service user requests the basic information of the STT engine.

Declaration
C#
Copy
public abstract Error GetInformation(out string engineUuid, out string engineName, out string engineSetting, out bool useNetwork)
Parameters
Type Name Description
System.String engineUuid

UUID of the engine.

System.String engineName

Name of the engine.

System.String engineSetting

The engine setting application (UI app)'s ID.

Boolean useNetwork

A variable for checking whether the network is used or not.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. OperationFailed
  3. InvalidParameter
Remarks

In order to upload the engine at Tizen Appstore, both a service application and a UI application are necessary. Therefore, engineSetting must be transferred to the engine service user.

API Level: 4
View Source

GetRecordingFormat(out AudioType, out Int32, out Int32)

Called when the engine service user gets the proper recording format of the STT engine. The recording format is used for creating the recorder.

Declaration
C#
Copy
public abstract Error GetRecordingFormat(out AudioType types, out int rate, out int channels)
Parameters
Type Name Description
AudioType types

The format used by the recorder.

System.Int32 rate

The sample rate used by the recorder.

System.Int32 channels

The number of channels used by the recorder.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
API Level: 4
View Source

Initialize()

Called when the engine service user initializes the STT engine. This callback function is called by the engine service user to request for the STT engine to be started.

Declaration
C#
Copy
public abstract Error Initialize()
Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidParameter
  3. InvalidState
  4. OperationFailed
API Level: 4
View Source

IsValidLanguage(String, out Boolean)

Called when the engine service user checks whether the corresponding language is valid or not in the STT engine.

Declaration
C#
Copy
public abstract Error IsValidLanguage(string language, out bool isValid)
Parameters
Type Name Description
System.String language

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

Boolean isValid

A variable for checking whether the corresponding language is valid or not. true to be valid, false to be invalid.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidParameter
API Level: 4
View Source

NeedAppCredential()

Called when the engine service user checks whether STT engine needs the application's credential.

Declaration
C#
Copy
public abstract bool NeedAppCredential()
Returns
Type Description
Boolean

true if the STT engine needs the application's credential, otherwise false.

API Level: 4
View Source

SendError(Error, String)

Sends the error to the engine service user.

Declaration
C#
Copy
public void SendError(Error error, string msg)
Parameters
Type Name Description
Error error

The error reason.

System.String msg

The error message.

Exceptions
Type Condition
UnauthorizedAccessException

Thrown in case of permission denied.

System.NotSupportedException

Thrown in case of not supported.

InvalidOperationException

Thrown in case of an operation failure.

API Level: 4
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone
View Source

SendResult(ResultEvent, String, String[], Int32, ResultMessage, IntPtr)

Sends the recognition result to the engine service user.

Declaration
C#
Copy
public void SendResult(ResultEvent resultEvent, string type, string[] result, int resultCount, ResultMessage msg, IntPtr timeInfo)
Parameters
Type Name Description
ResultEvent resultEvent

The result event.

System.String type

The recognition type, "stt.recognition.type.FREE", or "stt.recognition.type.FREE.PARTIAL".

System.String[] result

Result texts.

System.Int32 resultCount

Result text count.

ResultMessage msg

Engine message.

System.IntPtr timeInfo

The time information.

Remarks

This API is used in SetRecordingData() and Stop(), when the STT engine sends the recognition result to the engine service user. This function is called in the following situations: 1) After Stop() is called, 2) The end point of speech is detected from recording, or 3) Partial result is occurred. The recognition result must be transferred to the engine service user through this function. Also, the timeInfo must be transferred to ForEachResultTime(). The type of timeInfo is up to the STT engine developer.

Exceptions
Type Condition
UnauthorizedAccessException

Thrown in case of permission denied.

System.NotSupportedException

Thrown in case of not supported.

InvalidOperationException

Thrown in case of an operation failure.

API Level: 4
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone
View Source

SendSpeechStatus(SpeechStatus)

Sends the speech status to the engine service user when the STT engine notifies the change of the speech status.

Declaration
C#
Copy
public void SendSpeechStatus(SpeechStatus status)
Parameters
Type Name Description
SpeechStatus status

SpeechStatus

Remarks

This API is invoked when the STT engine wants to notify the change of the speech status anytime. Note that this API can be invoked for recognizing the speech.

Exceptions
Type Condition
UnauthorizedAccessException

Thrown in case of permission denied.

System.NotSupportedException

Thrown in case of not supported.

InvalidOperationException

Thrown in case of an operation failure.

API Level: 4
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone
View Source

SetPrivateDataRequestedDelegate(Engine.OutAction<String>)

Sets a callback delegate for requesting the private data.

Declaration
C#
Copy
public void SetPrivateDataRequestedDelegate(Engine.OutAction<string> callback)
Parameters
Type Name Description
Engine.OutAction<System.String> callback

The callback function. Called when the STT engine provides the engine service user with the private data. This callback function is called when the engine service user gets the private data from the STT engine. Out parameters: a = Key -- The key field of private data b = data -- The data field of private data The following error codes can be returned:

  1. None
  2. InvalidParameter
  3. OperationFailed
Exceptions
Type Condition
System.ArgumentException

Thrown in case of an invalid parameter.

UnauthorizedAccessException

Thrown in case of permission denied.

System.NotSupportedException

Thrown in case of not supported.

InvalidOperationException

Thrown in case of an operation failure.

API Level: 4
Privilege Level: public
Privilege: http://tizen.org/privilege/recorder
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone
View Source

SetPrivateDataSetDelegate(Engine.Action<String>)

Sets a callback function for setting the private data.

Declaration
C#
Copy
public void SetPrivateDataSetDelegate(Engine.Action<string> callback)
Parameters
Type Name Description
Engine.Action<System.String> callback

Called when the STT engine receives the private data from the engine service user. This callback function is called when the engine service user sends the private data to the STT engine. In Parameters: a = Key -- The key field of private data b = data -- The data field of private data The following error codes can be returned:

  1. None
  2. InvalidParameter
  3. OperationFailed
Exceptions
Type Condition
System.ArgumentException

Thrown in case of an invalid parameter.

UnauthorizedAccessException

Thrown in case of permission denied.

System.NotSupportedException

Thrown in case of not supported.

InvalidOperationException

Thrown in case of an operation failure.

API Level: 4
Privilege Level: public
Privilege: http://tizen.org/privilege/recorder
Feature: http://tizen.org/feature/speech.recognition http://tizen.org/feature/microphone
View Source

SetRecordingData(String, UInt32)

Called when the engine service user sets and sends the recording data for speech recognition. This callback function is called by the engine service user to send the recording data to the STT engine. The engine receives the recording data and uses for speech recognition. This function should be returned immediately after recording data copy.

Declaration
C#
Copy
public abstract Error SetRecordingData(string data, uint length)
Parameters
Type Name Description
System.String data

The recording data.

System.UInt32 length

The length of the recording data.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. InvalidParameter
  4. OperationFailed
API Level: 4
View Source

SetSilenceDetection(Boolean)

Called when the engine service user sets the silence detection. If the engine service user sets this option as 'TRUE', the STT engine will detect the silence (EPD) and send the callback event about it.

Declaration
C#
Copy
public abstract Error SetSilenceDetection(bool isSet)
Parameters
Type Name Description
Boolean isSet

A variable for setting the silence detection. true to detect the silence, false not to detect the silence.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. NotSupportedFeature
API Level: 4
View Source

Start(String, String, String, String, IntPtr)

Called when the engine service user starts to recognize the recording data. In this callback function, the STT engine must transfer the recognition result and userData to the engine service user using SendResult(). Also, if the STT engine needs the application's credential, it sets the credential granted to the application.

Declaration
C#
Copy
public abstract Error Start(string language, string type, string appid, string credential, IntPtr userData)
Parameters
Type Name Description
System.String language

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

System.String type

The recognition type, "stt.recognition.type.FREE", or "stt.recognition.type.FREE.PARTIAL".

System.String appid

The application ID.

System.String credential

The credential granted to the application.

System.IntPtr userData

The user data to be passed to the callback function.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. InvalidParameter
  4. InvalidLanguage
  5. OperationFailed
  6. NetworkDown
API Level: 4
View Source

Stop()

Called when the engine service user stops to recognize the recording data. This callback function is called by the engine service user to stop recording and to get the recognition result.

Declaration
C#
Copy
public abstract Error Stop()
Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidState
  3. OperationFailed
  4. NetworkDown
API Level: 4
View Source

SupportRecognitionType(String, out Boolean)

Called when the engine service user checks whether the STT engine supports the corresponding recognition type.

Declaration
C#
Copy
public abstract Error SupportRecognitionType(string type, out bool isSupported)
Parameters
Type Name Description
System.String type

The type for recognition, "stt.recognition.type.FREE", or "stt.recognition.type.FREE.PARTIAL".

Boolean isSupported

A variable for checking whether the STT engine supports the corresponding recognition type. true to support the recognition type, false not to support the recognition type.

Returns
Type Description
Error

The following error codes can be returned:

  1. None
  2. InvalidParameter
API Level: 4
View Source

SupportSilenceDetection()

Called when the engine service user checks whether the STT engine supports silence detection.

Declaration
C#
Copy
public abstract bool SupportSilenceDetection()
Returns
Type Description
Boolean

true to support silence detection, false not to support silence detection.

API Level: 4