Class Engine
Definition
- Assembly:
- Tizen.Uix.SttEngine.dll
This class represents the STT Engine, which has to be inherited to make the engine.
public abstract class Engine
- Inheritance
-
objectEngine
Constructors
View SourceEngine()
Public constructor.
Declaration
public Engine()
Methods
View SourceCancel()
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
public abstract Error Cancel()
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
CheckAppAgreed(string, out bool)
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
public abstract Error CheckAppAgreed(string appid, out bool isAgreed)
Parameters
Type | Name | Description |
---|---|---|
string | appid | The Application ID |
bool | 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:
|
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
public abstract Error Deinitialize()
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
EngineMain(int, string[])
Main function for the Speech-To-Text (STT) engine. This function is the main function for operating the STT engine.
Declaration
public void EngineMain(int argc, string[] argv)
Parameters
Type | Name | Description |
---|---|---|
int | argc | The number of arguments. |
string[] | argv | The arguments array. |
Remarks
ServiceAppMain should be used for working the engine after this function.
Exceptions
Type | Condition |
---|---|
System.UnauthorizedAccessException | Thrown in case of permission denied. |
System.NotSupportedException | Thrown in case of not supported. |
System.InvalidOperationException | Thrown in case of an operation failure. |
ForEachResultTime(IntPtr, ResultTime, IntPtr)
Called when the engine service user gets the result time information(stamp).
Declaration
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:
|
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.
ForEachSupportedLanguages(SupportedLanguages, IntPtr)
Called when the engine service user gets the whole supported language list.
Declaration
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:
|
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'.
GetInformation(out string, out string, out string, out bool)
Called when the engine service user requests the basic information of the STT engine.
Declaration
public abstract Error GetInformation(out string engineUuid, out string engineName, out string engineSetting, out bool useNetwork)
Parameters
Type | Name | Description |
---|---|---|
string | engineUuid | UUID of the engine. |
string | engineName | Name of the engine. |
string | engineSetting | The engine setting application (UI app)'s ID. |
bool | useNetwork | A variable for checking whether the network is used or not. |
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
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.
GetRecordingFormat(out AudioType, out int, out int)
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
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. |
int | rate | The sample rate used by the recorder. |
int | channels | The number of channels used by the recorder. |
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
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
public abstract Error Initialize()
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
IsValidLanguage(string, out bool)
Called when the engine service user checks whether the corresponding language is valid or not in the STT engine.
Declaration
public abstract Error IsValidLanguage(string language, out bool isValid)
Parameters
Type | Name | Description |
---|---|---|
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. |
bool | 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:
|
NeedAppCredential()
Called when the engine service user checks whether STT engine needs the application's credential.
Declaration
public abstract bool NeedAppCredential()
Returns
Type | Description |
---|---|
bool | true if the STT engine needs the application's credential, otherwise false. |
SendError(Error, string)
Sends the error to the engine service user.
Declaration
public void SendError(Error error, string msg)
Parameters
Type | Name | Description |
---|---|---|
Error | error | The error reason. |
string | msg | The error message. |
Exceptions
Type | Condition |
---|---|
System.UnauthorizedAccessException | Thrown in case of permission denied. |
System.NotSupportedException | Thrown in case of not supported. |
System.InvalidOperationException | Thrown in case of an operation failure. |
SendResult(ResultEvent, string, string[], int, ResultMessage, IntPtr)
Sends the recognition result to the engine service user.
Declaration
public void SendResult(ResultEvent resultEvent, string type, string[] result, int resultCount, ResultMessage msg, IntPtr timeInfo)
Parameters
Type | Name | Description |
---|---|---|
ResultEvent | resultEvent | The result event. |
string | type | The recognition type, "stt.recognition.type.FREE", or "stt.recognition.type.FREE.PARTIAL". |
string[] | result | Result texts. |
int | 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 |
---|---|
System.UnauthorizedAccessException | Thrown in case of permission denied. |
System.NotSupportedException | Thrown in case of not supported. |
System.InvalidOperationException | Thrown in case of an operation failure. |
SendSpeechStatus(SpeechStatus)
Sends the speech status to the engine service user when the STT engine notifies the change of the speech status.
Declaration
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 |
---|---|
System.UnauthorizedAccessException | Thrown in case of permission denied. |
System.NotSupportedException | Thrown in case of not supported. |
System.InvalidOperationException | Thrown in case of an operation failure. |
SetPrivateDataRequestedDelegate(OutAction<string>)
Sets a callback delegate for requesting the private data.
Declaration
public void SetPrivateDataRequestedDelegate(Engine.OutAction<string> callback)
Parameters
Type | Name | Description |
---|---|---|
Engine.OutAction<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:
|
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown in case of an invalid parameter. |
System.UnauthorizedAccessException | Thrown in case of permission denied. |
System.NotSupportedException | Thrown in case of not supported. |
System.InvalidOperationException | Thrown in case of an operation failure. |
SetPrivateDataSetDelegate(Action<string>)
Sets a callback function for setting the private data.
Declaration
public void SetPrivateDataSetDelegate(Engine.Action<string> callback)
Parameters
Type | Name | Description |
---|---|---|
Engine.Action<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:
|
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown in case of an invalid parameter. |
System.UnauthorizedAccessException | Thrown in case of permission denied. |
System.NotSupportedException | Thrown in case of not supported. |
System.InvalidOperationException | Thrown in case of an operation failure. |
SetRecordingData(string, uint)
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
public abstract Error SetRecordingData(string data, uint length)
Parameters
Type | Name | Description |
---|---|---|
string | data | The recording data. |
uint | length | The length of the recording data. |
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
SetSilenceDetection(bool)
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
public abstract Error SetSilenceDetection(bool isSet)
Parameters
Type | Name | Description |
---|---|---|
bool | 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:
|
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
public abstract Error Start(string language, string type, string appid, string credential, IntPtr userData)
Parameters
Type | Name | Description |
---|---|---|
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. |
string | type | The recognition type, "stt.recognition.type.FREE", or "stt.recognition.type.FREE.PARTIAL". |
string | appid | The application ID. |
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:
|
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
public abstract Error Stop()
Returns
Type | Description |
---|---|
Error | The following error codes can be returned:
|
SupportRecognitionType(string, out bool)
Called when the engine service user checks whether the STT engine supports the corresponding recognition type.
Declaration
public abstract Error SupportRecognitionType(string type, out bool isSupported)
Parameters
Type | Name | Description |
---|---|---|
string | type | The type for recognition, "stt.recognition.type.FREE", or "stt.recognition.type.FREE.PARTIAL". |
bool | 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:
|
SupportSilenceDetection()
Called when the engine service user checks whether the STT engine supports silence detection.
Declaration
public abstract bool SupportSilenceDetection()
Returns
Type | Description |
---|---|
bool | true to support silence detection, false not to support silence detection. |