--- /dev/null
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ public static partial class TTS
+ {
+ public static partial class Setting
+ {
+ [global::System.Runtime.InteropServices.DllImport("libtts_setting.so", EntryPoint = "tts_setting_initialize", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int Initialize();
+
+ [global::System.Runtime.InteropServices.DllImport("libtts_setting.so", EntryPoint = "tts_setting_finalize", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int Finalize();
+
+ [global::System.Runtime.InteropServices.DllImport("libtts_setting.so", EntryPoint = "tts_setting_set_voice", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int SetVoice(string language, int voiceType);
+
+ [global::System.Runtime.InteropServices.DllImport("libtts_setting.so", EntryPoint = "tts_setting_set_speed", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int SetSpeed(int speed);
+ }
+
+ internal static string GetErrorName(int error)
+ {
+ foreach (var e in Enum.GetValues(typeof(TtsError)))
+ {
+ if (error == (int)e)
+ return e.ToString();
+ }
+ return $"UNKNOWN ({error})";
+ }
+
+ private const int ErrorTts = -0x02F10000;
+ internal enum TtsError
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None, /* Successful */
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /* Out of Memory */
+ IoError = Tizen.Internals.Errors.ErrorCode.IoError, /* I/O error */
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /* Invalid parameter */
+ OutOfNetwork = Tizen.Internals.Errors.ErrorCode.Networkdown, /* Network is down */
+ TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut, /* No answer from the TTS service */
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /* Permission denied */
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /* TTS NOT supported */
+ InvalidState = ErrorTts | 0x01, /* Invalid state */
+ InvalidVoice = ErrorTts | 0x02, /* Invalid language */
+ EngineNotFound = ErrorTts | 0x03, /* No available engine */
+ OperationFailed = ErrorTts | 0x04, /* Operation failed */
+ AudioPolicyBlocked = ErrorTts | 0x05, /* Audio policy blocked */
+ NotSupportedFeature = ErrorTts | 0x06, /* Not supported feature of current engine */
+ ServiceReset = ErrorTts | 0x07, /* Service reset*/
+ ScreenReaderOff = ErrorTts | 0x08 /* Screen reader off */
+ };
+ }
+}
*
*/
+using System.Runtime.InteropServices;
+
internal static partial class Interop
{
internal static partial class Vconf
{
- [global::System.Runtime.InteropServices.DllImport("libvconf.so.0", EntryPoint = "vconf_get_bool")]
+ [global::System.Runtime.InteropServices.DllImport("libvconf.so.0", EntryPoint = "vconf_get_bool", CallingConvention = CallingConvention.Cdecl)]
internal static extern int GetVconfBool(string key, out bool value);
- [global::System.Runtime.InteropServices.DllImport("libvconf.so.0", EntryPoint = "vconf_set_bool")]
+ [global::System.Runtime.InteropServices.DllImport("libvconf.so.0", EntryPoint = "vconf_set_bool", CallingConvention = CallingConvention.Cdecl)]
internal static extern int SetVconfBool(string key, bool value);
}
}
{
base.OnCreate();
+ Interop.TTS.Setting.Initialize();
+
// log debug information
var tts = new Tizen.Uix.Tts.TtsClient();
var defaultVoice = tts.DefaultVoice;
volume.IsEnabled = false;
sections.Add(volume);
+ // The range of TTS speed is 1 to 15. (Normal is 8)
var speechRate = new SpeechRateRow();
speechRate.Slider.MinValue = speedRange.Min;
speechRate.Slider.MaxValue = speedRange.Max;
- // TODO: use actual value from vconf for CurrentValue, instead of speedRange.Normal
speechRate.Slider.CurrentValue = speedRange.Normal;
speechRate.Slider.ValueChanged += (s, e) =>
{
- // TODO: save speech rate to vconf
- SettingCore.Logger.Verbose($"Speech rate {e.CurrentValue}");
+ double ratio = (double)(e.CurrentValue - speechRate.Slider.MinValue) / (speechRate.Slider.MaxValue - speechRate.Slider.MinValue);
+ int speed = (int)((speedRange.Max - speedRange.Min) * ratio + speedRange.Min);
+ SettingCore.Logger.Verbose($"Speech rate {speed}");
+
+ Interop.TTS.Setting.SetSpeed(speed);
};
sections.Add(speechRate);
return defaultVoice.ToString();
}
+ protected override void OnDestroy()
+ {
+ Interop.TTS.Setting.Finalize();
+ base.OnDestroy();
+ }
}
}