2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.InteropServices;
23 /// Partial interop class.
25 internal static partial class Interop
28 /// Tts interop class.
30 internal static class Tts
32 internal const string LogTag = "Tizen.Uix.Tts";
34 private const int ErrorTts = -0x02F10000;
36 internal enum TtsError
38 None = Tizen.Internals.Errors.ErrorCode.None, /* Successful */
39 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /* Out of Memory */
40 IoError = Tizen.Internals.Errors.ErrorCode.IoError, /* I/O error */
41 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /* Invalid parameter */
42 OutOfNetwork = Tizen.Internals.Errors.ErrorCode.Networkdown, /* Network is down */
43 TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut, /* No answer from the STT service */
44 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /* Permission denied */
45 NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /* STT NOT supported */
46 InvalidState = ErrorTts | 0x01, /* Invalid state */
47 InvalidVoice = ErrorTts | 0x02, /* Invalid language */
48 EngineNotFound = ErrorTts | 0x03, /* No available engine */
49 OperationFailed = ErrorTts | 0x04, /* Operation failed */
50 AudioPolicyBlocked = ErrorTts | 0x05, /* Audio policy blocked */
51 NotSupportedFeature = ErrorTts | 0x06, /* Not supported feature of current engine*/
52 ServiceReset = ErrorTts | 0x07 /* Service reset*/
55 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
56 internal delegate void TtsStateChangedCB(IntPtr handle, State previous, State current, IntPtr userData);
58 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
59 internal delegate void TtsUtteranceStartedCB(IntPtr handle, int uttId, IntPtr userData);
61 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
62 internal delegate void TtsUtteranceCompletedCB(IntPtr handle, int uttId, IntPtr userData);
64 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
65 internal delegate void TtsErrorCB(IntPtr handle, int uttId, TtsError reason, IntPtr userData);
67 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
68 internal delegate bool TtsSupportedVoiceCB(IntPtr handle, IntPtr language, int voiceType, IntPtr userData);
70 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
71 internal delegate void TtsDefaultVoiceChangedCB(IntPtr handle, IntPtr previous_language, int previous_voice_type, IntPtr current_language, int current_voice_type, IntPtr userData);
73 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
74 internal delegate void TtsEngineChangedCB(IntPtr handle, IntPtr engine_id, IntPtr language, int voice_type, bool need_credential, IntPtr userData);
76 [DllImport(Libraries.Tts, EntryPoint = "tts_create", CallingConvention = CallingConvention.Cdecl)]
77 internal static extern TtsError TtsCreate(out IntPtr handle);
79 [DllImport(Libraries.Tts, EntryPoint = "tts_destroy", CallingConvention = CallingConvention.Cdecl)]
80 internal static extern TtsError TtsDestroy(IntPtr handle);
82 [DllImport(Libraries.Tts, EntryPoint = "tts_set_mode", CallingConvention = CallingConvention.Cdecl)]
83 internal static extern TtsError TtsSetMode(IntPtr handle, Mode m);
85 [DllImport(Libraries.Tts, EntryPoint = "tts_get_mode", CallingConvention = CallingConvention.Cdecl)]
86 internal static extern TtsError TtsGetMode(IntPtr handle, out Mode m);
88 [DllImport(Libraries.Tts, EntryPoint = "tts_set_credential", CallingConvention = CallingConvention.Cdecl)]
89 internal static extern TtsError TtsSetCredential(IntPtr handle, string credential);
91 [DllImport(Libraries.Tts, EntryPoint = "tts_prepare", CallingConvention = CallingConvention.Cdecl)]
92 internal static extern TtsError TtsPrepare(IntPtr handle);
94 [DllImport(Libraries.Tts, EntryPoint = "tts_unprepare", CallingConvention = CallingConvention.Cdecl)]
95 internal static extern TtsError TtsUnprepare(IntPtr handle);
97 [DllImport(Libraries.Tts, EntryPoint = "tts_foreach_supported_voices", CallingConvention = CallingConvention.Cdecl)]
98 internal static extern TtsError TtsForeachSupportedVoices(IntPtr handle, TtsSupportedVoiceCB callback, IntPtr userData);
100 [DllImport(Libraries.Tts, EntryPoint = "tts_get_default_voice", CallingConvention = CallingConvention.Cdecl)]
101 internal static extern TtsError TtsGetDefaultVoice(IntPtr handle, out string language, out int voice_type);
103 [DllImport(Libraries.Tts, EntryPoint = "tts_set_private_data", CallingConvention = CallingConvention.Cdecl)]
104 internal static extern TtsError TtsSetPrivateData(IntPtr handle, string key, string data);
106 [DllImport(Libraries.Tts, EntryPoint = "tts_get_private_data", CallingConvention = CallingConvention.Cdecl)]
107 internal static extern TtsError TtsGetPrivateData(IntPtr handle, string key, out string data);
109 [DllImport(Libraries.Tts, EntryPoint = "tts_get_max_text_size", CallingConvention = CallingConvention.Cdecl)]
110 internal static extern TtsError TtsGetMaxTextSize(IntPtr handle, out uint size);
112 [DllImport(Libraries.Tts, EntryPoint = "tts_get_state", CallingConvention = CallingConvention.Cdecl)]
113 internal static extern TtsError TtsGetState(IntPtr handle, out State state);
115 [DllImport(Libraries.Tts, EntryPoint = "tts_get_speed_range", CallingConvention = CallingConvention.Cdecl)]
116 internal static extern TtsError TtsGetSpeedRange(IntPtr handle, out int min, out int normal, out int max);
118 [DllImport(Libraries.Tts, EntryPoint = "tts_get_error_message", CallingConvention = CallingConvention.Cdecl)]
119 internal static extern TtsError TtsGetErrorMessage(IntPtr handle, out string err_msg);
121 [DllImport(Libraries.Tts, EntryPoint = "tts_is_recognition_type_supported", CallingConvention = CallingConvention.Cdecl)]
122 internal static extern TtsError TtsIsRecognitionTypeSupported(IntPtr handle, string type, out bool support);
124 [DllImport(Libraries.Tts, EntryPoint = "tts_add_text", CallingConvention = CallingConvention.Cdecl)]
125 internal static extern TtsError TtsAddText(IntPtr handle, string text, string language, int voice_type, int speed, out int uttId);
127 [DllImport(Libraries.Tts, EntryPoint = "tts_play", CallingConvention = CallingConvention.Cdecl)]
128 internal static extern TtsError TtsPlay(IntPtr handle);
130 [DllImport(Libraries.Tts, EntryPoint = "tts_stop", CallingConvention = CallingConvention.Cdecl)]
131 internal static extern TtsError TtsStop(IntPtr handle);
133 [DllImport(Libraries.Tts, EntryPoint = "tts_pause", CallingConvention = CallingConvention.Cdecl)]
134 internal static extern TtsError TtsPause(IntPtr handle);
136 [DllImport(Libraries.Tts, EntryPoint = "tts_set_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
137 internal static extern TtsError TtsSetStateChangedCB(IntPtr handle, TtsStateChangedCB callback, IntPtr userData);
139 [DllImport(Libraries.Tts, EntryPoint = "tts_unset_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
140 internal static extern TtsError TtsUnsetStateChangedCB(IntPtr handle);
142 [DllImport(Libraries.Tts, EntryPoint = "tts_set_utterance_started_cb", CallingConvention = CallingConvention.Cdecl)]
143 internal static extern TtsError TtsSetUtteranceStartedCB(IntPtr handle, TtsUtteranceStartedCB callback, IntPtr userData);
145 [DllImport(Libraries.Tts, EntryPoint = "tts_unset_utterance_started_cb", CallingConvention = CallingConvention.Cdecl)]
146 internal static extern TtsError TtsUnsetUtteranceStartedCB(IntPtr handle);
148 [DllImport(Libraries.Tts, EntryPoint = "tts_set_utterance_completed_cb", CallingConvention = CallingConvention.Cdecl)]
149 internal static extern TtsError TtsSetUtteranceCompletedCB(IntPtr handle, TtsUtteranceCompletedCB callback, IntPtr userData);
151 [DllImport(Libraries.Tts, EntryPoint = "tts_unset_utterance_completed_cb", CallingConvention = CallingConvention.Cdecl)]
152 internal static extern TtsError TtsUnsetUtteranceCompletedCB(IntPtr handle);
154 [DllImport(Libraries.Tts, EntryPoint = "tts_set_error_cb", CallingConvention = CallingConvention.Cdecl)]
155 internal static extern TtsError TtsSetErrorCB(IntPtr handle, TtsErrorCB callback, IntPtr userData);
157 [DllImport(Libraries.Tts, EntryPoint = "tts_unset_error_cb", CallingConvention = CallingConvention.Cdecl)]
158 internal static extern TtsError TtsUnsetErrorCB(IntPtr handle);
160 [DllImport(Libraries.Tts, EntryPoint = "tts_set_default_voice_changed_cb", CallingConvention = CallingConvention.Cdecl)]
161 internal static extern TtsError TtsSetDefaultVoiceChangedCB(IntPtr handle, TtsDefaultVoiceChangedCB callback, IntPtr userData);
163 [DllImport(Libraries.Tts, EntryPoint = "tts_unset_default_voice_changed_cb", CallingConvention = CallingConvention.Cdecl)]
164 internal static extern TtsError TtsUnsetDefaultVoiceChangedCB(IntPtr handle);
166 [DllImport(Libraries.Tts, EntryPoint = "tts_set_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
167 internal static extern TtsError TtsSetEngineChangedCB(IntPtr handle, TtsEngineChangedCB callback, IntPtr userData);
169 [DllImport(Libraries.Tts, EntryPoint = "tts_unset_engine_changed_cb", CallingConvention = CallingConvention.Cdecl)]
170 internal static extern TtsError TtsUnsetEngineChangedCB(IntPtr handle);