internal delegate Error ForEachSupportedLangsCb(SupportedLanguages cb, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error IsValidLanguageCb(IntPtr language, IntPtr isValid);
+ internal delegate Error IsValidLanguageCb(string language, out byte isValid);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool SupportSilenceDetectionCb();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error SupportRecognitionTypeCb(string type, out bool isSupported);
+ internal delegate Error SupportRecognitionTypeCb(string type, out byte isSupported);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate Error GetRecordingFormatCb(out AudioType types, out int rate, out int channels);
internal delegate Error SetSilenceDetectionCb(bool isSet);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error CheckAppAgreedCb(string appid, out bool isAgreed);
+ internal delegate Error CheckAppAgreedCb(string appid, out byte isAgreed);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool NeedAppCredentialCb();
internal delegate Error ForEachResultTimeCb(IntPtr timeInfo, ResultTime callback, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error StartCb(IntPtr language, IntPtr type, IntPtr appid, IntPtr credential, IntPtr userData);
+ internal delegate Error StartCb(string language, string type, string appid, string credential, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate Error SetRecordingDataCb(string data, uint length);
internal delegate Error CancelCb();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error GetInfoCb(out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out IntPtr useNetwork);
+ internal delegate Error GetInfoCb(out string engineUuid, out string engineName, out string engineSetting, out byte useNetwork);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate Error PrivateDataSetCb(string key, string data);
_callbackStructGCHandle.CallbackStruct.supportedLanaguge = ForEachSupportedLanguages;
_callbackStructGCHandle.CallbackStruct.validLanaguage = _isValidLanguageCb;
_callbackStructGCHandle.CallbackStruct.silence = SupportSilenceDetection;
- _callbackStructGCHandle.CallbackStruct.recognitionType = SupportRecognitionType;
+ _callbackStructGCHandle.CallbackStruct.recognitionType = _supportRecognitionTypeCb;
_callbackStructGCHandle.CallbackStruct.recordingFormat = GetRecordingFormat;
_callbackStructGCHandle.CallbackStruct.resultTime = ForEachResultTime;
_callbackStructGCHandle.CallbackStruct.silenceDetection = SetSilenceDetection;
- _callbackStructGCHandle.CallbackStruct.start = _startCb;
+ _callbackStructGCHandle.CallbackStruct.start = Start;
_callbackStructGCHandle.CallbackStruct.recordingData = SetRecordingData;
_callbackStructGCHandle.CallbackStruct.stop = Stop;
_callbackStructGCHandle.CallbackStruct.cancel = Cancel;
- _callbackStructGCHandle.CallbackStruct.checkAppAgreed = CheckAppAgreed;
+ _callbackStructGCHandle.CallbackStruct.checkAppAgreed = _checkAppAgreedCb;
_callbackStructGCHandle.CallbackStruct.needAppCredential = NeedAppCredential;
_structIntPtrHandle = Marshal.AllocHGlobal(Marshal.SizeOf(_callbackStructGCHandle.CallbackStruct));
Marshal.StructureToPtr<RequestCallbackStruct>(_callbackStructGCHandle.CallbackStruct, _structIntPtrHandle, false);
}
- private StartCb _startCb = (IntPtr language, IntPtr type, IntPtr appid, IntPtr credential, IntPtr userData) =>
+ private IsValidLanguageCb _isValidLanguageCb = (string langauge, out byte isValid) =>
{
- string lan = null;
- string typ = null;
- string apid = null;
- string cre = null;
- if (language != null)
- lan = Marshal.PtrToStringAnsi(language);
- if (type != null)
- typ = Marshal.PtrToStringAnsi(type);
- if (appid != null)
- apid = Marshal.PtrToStringAnsi(appid);
- if (credential != null)
- cre = Marshal.PtrToStringAnsi(credential);
- return _engine.Start(lan, typ, apid, cre, IntPtr.Zero);
+ bool valid;
+ Error err = _engine.IsValidLanguage(langauge, out valid);
+ if (true == valid)
+ {
+ isValid = 1;
+ }
+ else
+ {
+ isValid = 0;
+ }
+
+ return err;
+ };
+
+ private CheckAppAgreedCb _checkAppAgreedCb = (string appid, out byte isAgreed) =>
+ {
+ bool agreed;
+ Error err = _engine.CheckAppAgreed(appid, out agreed);
+ if (true == agreed)
+ {
+ isAgreed = 1;
+ }
+ else
+ {
+ isAgreed = 0;
+ }
+
+ return err;
};
- private IsValidLanguageCb _isValidLanguageCb = (IntPtr langauge, IntPtr isValid) =>
+ private SupportRecognitionTypeCb _supportRecognitionTypeCb = (string type, out byte isSupported) =>
{
- string langaugeStr = Marshal.PtrToStringAnsi(langauge);
- bool valid;
- Error err = _engine.IsValidLanguage(langaugeStr, out valid);
- if (valid == true)
+ bool supported;
+ Error err = _engine.SupportRecognitionType(type, out supported);
+ if (true == supported)
{
- Marshal.WriteByte(isValid, 0, 1);
+ isSupported = 1;
}
else
{
- Marshal.WriteByte(isValid, 0, 0);
+ isSupported = 0;
}
+
return err;
};
- private GetInfoCb _getInfoCb = (out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out IntPtr useNetwork) =>
+ private GetInfoCb _getInfoCb = (out string engineUuid, out string engineName, out string engineSetting, out byte useNetwork) =>
{
- string uuid;
- string name;
- string setting;
bool network;
- Error err = _engine.GetInformation(out uuid, out name, out setting, out network);
- int size = Marshal.SizeOf<int>();
- IntPtr pBool = Marshal.AllocHGlobal(size);
- if (network == true)
+
+ Error err = _engine.GetInformation(out engineUuid, out engineName, out engineSetting, out network);
+ if (true == network)
{
- Marshal.WriteInt32(pBool, 0, 1);
+ useNetwork = 1;
}
else
{
- Marshal.WriteInt32(pBool, 0, 0);
+ useNetwork = 0;
}
- engineUuid = Marshal.StringToHGlobalAnsi(uuid);
- engineName = Marshal.StringToHGlobalAnsi(name);
- engineSetting = Marshal.StringToHGlobalAnsi(setting);
- useNetwork = pBool;
+
return err;
};
internal delegate bool NeedAppCredentialCb();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error StartSynthesisCb(IntPtr language, int type, IntPtr text, int speed, IntPtr appid, IntPtr credential, IntPtr userData);
+ internal delegate Error StartSynthesisCb(string language, int type, string text, int speed, string appid, string credential, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate Error CancelSynthesisCb();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate Error GetInfoCb(out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out byte useNetwork);
+ internal delegate Error GetInfoCb(out string engineUuid, out string engineName, out string engineSetting, out byte useNetwork);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate Error PrivateDataSetCb(string key, string data);
/// <summary>
/// Called when the TTS engine informs the engine service user about whole supported language and voice type list.
- /// This callback function is implemented by the engine service user, therefore, the engine developer does NOT have to implement this callback function.
+ /// This callback function is implemented by the engine service user, therefore, the engine developer does NOT have to implement this callback function.
/// </summary>
/// <remarks>
/// This callback function is called by ForEachSupportedVoices() to inform the whole supported voice list. userData must be transferred from ForEachSupportedVoices().
_callbackStructGCHandle.CallbackStruct.pitch = SetPitch;
_callbackStructGCHandle.CallbackStruct.loadVoice = LoadVoice;
_callbackStructGCHandle.CallbackStruct.unloadVoice = UnloadVoice;
- _callbackStructGCHandle.CallbackStruct.startSynthesis = _startSynthesisCb;
+ _callbackStructGCHandle.CallbackStruct.startSynthesis = StartSynthesis;
_callbackStructGCHandle.CallbackStruct.cancelSynthesis = CancelSynthesis;
_callbackStructGCHandle.CallbackStruct.checkAppAgreed = _checkAppAgreedCb;
_callbackStructGCHandle.CallbackStruct.needAppCredential = NeedAppCredential;
private IsValidVoiceCb _validVoiceCb = (string language, int type, out byte isValid) =>
{
- Log.Error(LogTag, "_isValidVoiceCb called");
bool valid;
Error err = _engine.IsValidVoice(language, type, out valid);
- Log.Error(LogTag, "check valid and insert value" + valid);
if (true == valid)
{
isValid = 1;
return err;
};
- private StartSynthesisCb _startSynthesisCb = (IntPtr language, int type, IntPtr text, int speed, IntPtr appid, IntPtr credential, IntPtr userData) =>
+ private GetInfoCb _getInfoCb = (out string engineUuid, out string engineName, out string engineSetting, out byte useNetwork) =>
{
- string lan = null;
- string txt = null;
- string apid = null;
- string cre = null;
- if (language != null)
- lan = Marshal.PtrToStringAnsi(language);
- if (text != null)
- txt = Marshal.PtrToStringAnsi(text);
- if (appid != null)
- apid = Marshal.PtrToStringAnsi(appid);
- if (credential != null)
- cre = Marshal.PtrToStringAnsi(credential);
- return _engine.StartSynthesis(lan, type, txt, speed, apid, cre, IntPtr.Zero);
- };
-
- private GetInfoCb _getInfoCb = (out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out byte useNetwork) =>
- {
- string uuid;
- string name;
- string setting;
bool network;
- Error err = _engine.GetInformation(out uuid, out name, out setting, out network);
+
+ Error err = _engine.GetInformation(out engineUuid, out engineName, out engineSetting, out network);
if (true == network)
{
useNetwork = 1;
{
useNetwork = 0;
}
- engineUuid = Marshal.StringToHGlobalAnsi(uuid);
- engineName = Marshal.StringToHGlobalAnsi(name);
- engineSetting = Marshal.StringToHGlobalAnsi(setting);
+
return err;
};