2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUixSpeech_TextToSpeechImpl.h
20 * @brief This is the implementation file for the _TextToSpeechImpl class.
22 * This files contains implementation of the _TextToSpeechImpl class.
26 #include <FBaseColIList.h>
27 #include <FBaseColArrayList.h>
28 #include <FBaseString.h>
29 #include <FBaseUtilStringTokenizer.h>
30 #include <FLclLocale.h>
31 #include <FUixSpeechTextToSpeech.h>
32 #include <FBaseSysLog.h>
33 #include <FBase_StringConverter.h>
34 #include <FUixSpeech_TextToSpeechImpl.h>
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Locales;
45 _OSP_EXPORT_ Tizen::Uix::Speech::_ITextToSpeech*
46 _GetInstance_FUixTextToSpeechImpl(void)
48 return new (std::nothrow) Tizen::Uix::Speech::_TextToSpeechImpl();
52 _ReleaseInstance_FUixTextToSpeechImpl(Tizen::Uix::Speech::_ITextToSpeech* pInstacne)
61 namespace Tizen { namespace Uix { namespace Speech
64 _TextToSpeechImpl::TtsStateChangedReceiver(tts_h ttsHandle, tts_state_e previousState, tts_state_e currentState, void* pTtsInstance)
66 SysLog(NID_UIX_SPEECH, "The current state is changed to '%s' from '%s'.",
67 GetEngineStateMessage(currentState), GetEngineStateMessage(previousState));
69 _TextToSpeechImpl* pInstance = static_cast<_TextToSpeechImpl*>(pTtsInstance);
70 ITextToSpeechEventListener* pListener = pInstance->__pTextToSpeechListener;
72 if ((previousState == TTS_STATE_CREATED) && (currentState == TTS_STATE_READY))
74 char *pDefaultLang = null;
75 tts_voice_type_e defaultVoiceType;
77 int ttsError = tts_get_default_voice(ttsHandle, &pDefaultLang, &defaultVoiceType);
78 if (ttsError == TTS_ERROR_NONE)
80 SysLog(NID_UIX_SPEECH, "The default language is '%s', and voice type is '%d'." , pDefaultLang, defaultVoiceType);
81 const Locale* pDefaultLocale = ConvertEngineLocaleToOspN(pDefaultLang);
82 *pInstance->__pCurrentLocale = *pDefaultLocale;
84 delete pDefaultLocale;
88 ttsError = tts_foreach_supported_voices(ttsHandle, TtsSupportedLocaleListGetter, (void*)(pInstance->__pSupportedLocaleList));
89 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to get supported voices", GetEngineErrorMessage(ttsError));
91 pInstance->__isInitialized = true;
92 pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_READY;
94 pListener->OnTextToSpeechInitialized();
95 pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_READY);
97 else if ((previousState == TTS_STATE_READY || previousState == TTS_STATE_PAUSED) && (currentState == TTS_STATE_PLAYING))
99 pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_PLAYING;
100 pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_PLAYING);
102 else if ((previousState == TTS_STATE_PLAYING) && (currentState == TTS_STATE_PAUSED))
104 pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_PAUSED;
105 pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_PAUSED);
107 else if ((previousState == TTS_STATE_PLAYING || previousState == TTS_STATE_PAUSED) && (currentState == TTS_STATE_READY))
109 pInstance->__currentStatus = TEXT_TO_SPEECH_STATUS_READY;
110 pListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_READY);
114 SysLog(NID_UIX_SPEECH, "The unknown state is changed to '%s' from '%s'.",
115 GetEngineStateMessage(currentState), GetEngineStateMessage(previousState));
120 _TextToSpeechImpl::TtsStartedReceiver(tts_h ttsHandle, int utteranceId, void* pListener)
122 SysLog(NID_UIX_SPEECH, "The utterance(%d) has started.", utteranceId);
126 _TextToSpeechImpl::TtsCompletedReceiver(tts_h ttsHandle, int utteranceId, void* pTtsInstance)
128 _TextToSpeechImpl* pInstance = static_cast<_TextToSpeechImpl*>(pTtsInstance);
129 ITextToSpeechEventListener* pListener = pInstance->__pTextToSpeechListener;
131 SysLog(NID_UIX_SPEECH, "The utterance id is '%d' and the request count is '%d'.",
132 utteranceId, pInstance->__appendRequsetCount);
134 if ((--(pInstance->__appendRequsetCount) == 0) || (pInstance->__currentRequestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE))
136 SysLog(NID_UIX_SPEECH, "Automatically, Stop() method was called.");
137 int ttsError = tts_stop(ttsHandle);
138 SysTryReturnVoidResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM,
139 "[%s] Failed to stop.", GetEngineErrorMessage(ttsError));
142 static_cast <ITextToSpeechEventListener*>(pListener)->OnTextToSpeechCompleted();
146 _TextToSpeechImpl::TtsErrorReceiver(tts_h ttsHandle, int ttsUtteranceId, tts_error_e error, void* pListener)
148 SysLog(NID_UIX_SPEECH, "[%s] Error occurred.", GetEngineErrorMessage(error));
150 TextToSpeechError ttsError;
154 case TTS_ERROR_OUT_OF_MEMORY:
155 ttsError = TEXT_TO_SPEECH_ERROR_OUT_OF_MEMORY;
157 case TTS_ERROR_IO_ERROR:
158 ttsError = TEXT_TO_SPEECH_ERROR_IO_ERROR;
160 case TTS_ERROR_OUT_OF_NETWORK:
161 ttsError = TEXT_TO_SPEECH_ERROR_NETWORK_ERROR;
163 case TTS_ERROR_ENGINE_NOT_FOUND:
164 ttsError = TEXT_TO_SPEECH_ERROR_UNSUPPORTED_SERVICE;
166 case TTS_ERROR_TIMED_OUT:
167 ttsError = TEXT_TO_SPEECH_ERROR_TIME_OUT;
170 ttsError = TEXT_TO_SPEECH_ERROR_SYSTEM_ERROR;
174 static_cast <ITextToSpeechEventListener*>(pListener)->OnTextToSpeechErrorOccurred(ttsError);
178 _TextToSpeechImpl::TtsSupportedLocaleListGetter(tts_h ttsHandle, const char* pLanguage, tts_voice_type_e voiceType, void* pLocaleList)
180 SysLog(NID_UIX_SPEECH, "The language is '%s' and the voice type is '%s'.",
181 pLanguage, GetEngineVoiceTypeMessage(voiceType));
183 const Locale* pLocale = ConvertEngineLocaleToOspN(String(pLanguage));
186 static_cast <ArrayList*>(pLocaleList)->RemoveAll(true);
187 return false; // escape call back loop
190 if (pLocale->GetLanguageCode() == LANGUAGE_INVALID)
192 SysLog(NID_UIX_SPEECH, "The '%s' language is not supported.", pLanguage);
197 result r = static_cast<ArrayList*>(pLocaleList)->Add(*pLocale);
200 static_cast<ArrayList*>(pLocaleList)->RemoveAll(true);
201 return false; // escape call back loop
205 return true; // continue call back loop
208 _TextToSpeechImpl::_TextToSpeechImpl(void)
210 , __isInitialized(false)
211 , __currentRequestMode(TEXT_TO_SPEECH_REQUEST_MODE_APPEND)
212 , __appendRequsetCount(0)
213 , __pCurrentLocale(null)
214 , __pSupportedLocaleList(null)
215 , __pTextToSpeechListener(null)
216 , __currentStatus(TEXT_TO_SPEECH_STATUS_NONE)
217 , __speechRate(TEXT_TO_SPEECH_SPEECH_RATE_SYSTEM_SETTING)
221 _TextToSpeechImpl::~_TextToSpeechImpl(void)
223 tts_state_e ttsState = TTS_STATE_READY;
225 int ttsError = tts_get_state(__ttsHandle, &ttsState);
226 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to get the current state.", GetEngineErrorMessage(ttsError));
228 if (ttsState == TTS_STATE_PLAYING || ttsState == TTS_STATE_PAUSED)
230 ttsError = tts_stop(__ttsHandle);
231 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to stop.", GetEngineErrorMessage(ttsError));
236 ttsError = tts_unprepare(__ttsHandle);
237 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unprepare.", GetEngineErrorMessage(ttsError));
239 ttsError = tts_unset_utterance_completed_cb(__ttsHandle);
240 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the utterance completed callback.", GetEngineErrorMessage(ttsError));
242 ttsError = tts_unset_utterance_started_cb(__ttsHandle);
243 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the utterance started callback.", GetEngineErrorMessage(ttsError));
245 ttsError = tts_unset_state_changed_cb(__ttsHandle);
246 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the state changed callback.", GetEngineErrorMessage(ttsError));
248 ttsError = tts_unset_error_cb(__ttsHandle);
249 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to unset the error callback.", GetEngineErrorMessage(ttsError));
252 ttsError = tts_destroy(__ttsHandle);
253 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to destroy.", GetEngineErrorMessage(ttsError));
255 delete __pCurrentLocale;
257 if (__pSupportedLocaleList != null)
259 __pSupportedLocaleList->RemoveAll(true);
260 delete __pSupportedLocaleList;
265 _TextToSpeechImpl::Construct(ITextToSpeechEventListener& listener)
267 int ttsError = tts_create(&__ttsHandle);
268 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to create", GetEngineErrorMessage(ttsError));
269 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to create.");
271 Locale *pLocale = new (std::nothrow) Locale(LANGUAGE_INVALID, COUNTRY_INVALID);
272 SysTryReturnResult(NID_UIX_SPEECH, pLocale != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
274 ArrayList* pLocaleList = new (std::nothrow) ArrayList();
275 SysTryReturnResult(NID_UIX_SPEECH, pLocaleList != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
277 result r = pLocaleList->Construct();
278 SysTryReturnResult(NID_UIX_SPEECH, r == E_SUCCESS, E_OUT_OF_MEMORY, "The memory is insufficient.");
280 __pCurrentLocale = pLocale;
281 __pSupportedLocaleList = pLocaleList;
282 __pTextToSpeechListener = &listener;
288 _TextToSpeechImpl::Initialize(void)
290 SysAssertf(__isInitialized != true,
291 "Already calling Initialize() twice or more on a same instance is not allowed for this class.");
293 int ttsError = tts_set_error_cb(__ttsHandle, TtsErrorReceiver, (void*)(__pTextToSpeechListener));
294 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the error callback.", GetEngineErrorMessage(ttsError));
295 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
297 ttsError = tts_set_state_changed_cb(__ttsHandle, TtsStateChangedReceiver, (void*)(this));
298 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the state changed callback.", GetEngineErrorMessage(ttsError));
299 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
301 ttsError = tts_set_utterance_started_cb(__ttsHandle, TtsStartedReceiver, (void*)(__pTextToSpeechListener));
302 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the utterance started callback.", GetEngineErrorMessage(ttsError));
303 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
305 ttsError = tts_set_utterance_completed_cb(__ttsHandle, TtsCompletedReceiver, (void*)(this));
306 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to set the utterance completed callback.", GetEngineErrorMessage(ttsError));
307 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
309 ttsError = tts_prepare(__ttsHandle);
310 SysTryLog(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, "[%s] Failed to prepare", GetEngineErrorMessage(ttsError));
311 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_OUT_OF_MEMORY, "The memory is insufficient.");
317 _TextToSpeechImpl::Speak(const String& text, TextToSpeechRequestMode requestMode)
319 SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
320 "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
322 result r = E_SUCCESS;
323 tts_state_e ttsState = TTS_STATE_READY;
325 int ttsError = tts_get_state(__ttsHandle, &ttsState);
326 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
328 const char* pLanguage = ConvertOspLocaleToEngineN(*__pCurrentLocale);
329 SysTryReturnResult(NID_UIX_SPEECH, pLanguage != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
331 if (requestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE && ttsState != TTS_STATE_READY)
336 const char* pTextN = _StringConverter::CopyToCharArrayN(text);
337 tts_speed_e ttsSpeed = ConvertOspSpeedToEngine(__speechRate);
338 int ttsUtteranceId = 0;
340 SysTryCatchLabel(NID_UIX_SPEECH, pTextN != null, r = E_OUT_OF_MEMORY, CATCH_LANG, E_OUT_OF_MEMORY,
341 "[E_OUT_OF_MEMORY] The memory is insufficient.");
343 ttsError = tts_add_text(__ttsHandle, pTextN, pLanguage, TTS_VOICE_TYPE_AUTO, ttsSpeed, &ttsUtteranceId);
344 SysTryCatch(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, r = E_OUT_OF_MEMORY, E_SYSTEM, "[E_SYSTEM] Failed to add a text.");
346 if (requestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE || __appendRequsetCount == 0)
348 __appendRequsetCount = 0;
350 ttsError = tts_play(__ttsHandle);
351 SysTryCatch(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] Failed to play.", GetEngineErrorMessage(ttsError));
354 __appendRequsetCount++;
355 __currentRequestMode = requestMode;
357 if (__appendRequsetCount == 1)
359 __pTextToSpeechListener->OnTextToSpeechStatusChanged(TEXT_TO_SPEECH_STATUS_SYNTHESIZING);
362 SysLog(NID_UIX_SPEECH, "The utterance id is '%d', the request count is '%d' and the request mode is '%s'.",
363 ttsUtteranceId, __appendRequsetCount, (requestMode == TEXT_TO_SPEECH_REQUEST_MODE_REPLACE ? "Replace" : "Append"));
375 _TextToSpeechImpl::Stop(void)
377 SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
378 "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
380 tts_state_e ttsState = TTS_STATE_READY;
382 int ttsError = tts_get_state(__ttsHandle, &ttsState);
383 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
384 SysTryReturnResult(NID_UIX_SPEECH, ttsState != TTS_STATE_READY, E_INVALID_OPERATION,
385 "The TTS state should be TTS_STATUS_PLAYING or TTS_STATUS_PAUSED.");
387 ttsError = tts_stop(__ttsHandle);
388 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to stop.");
389 __appendRequsetCount = 0;
395 _TextToSpeechImpl::Pause(void)
397 SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
398 "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.")
400 tts_state_e ttsState = TTS_STATE_READY;
402 int ttsError = tts_get_state(__ttsHandle, &ttsState);
403 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
404 SysTryReturnResult(NID_UIX_SPEECH, ttsState == TTS_STATE_PLAYING, E_INVALID_OPERATION, "The TTS state should be TTS_STATUS_PLAYING.");
406 ttsError = tts_pause(__ttsHandle);
407 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to pause.");
413 _TextToSpeechImpl::Resume(void)
415 SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
416 "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
418 tts_state_e ttsState = TTS_STATE_READY;
420 int ttsError = tts_get_state(__ttsHandle, &ttsState);
421 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to get the current state.");
422 SysTryReturnResult(NID_UIX_SPEECH, ttsState == TTS_STATE_PAUSED, E_INVALID_OPERATION, "The TTS state should be TTS_STATUS_PAUSED.");
424 ttsError = tts_play(__ttsHandle);
425 SysTryReturnResult(NID_UIX_SPEECH, ttsError == TTS_ERROR_NONE, E_SYSTEM, "Failed to resume.");
431 _TextToSpeechImpl::SetLocale(const Locale& locale)
433 SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
434 "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.")
435 SysTryReturnResult(NID_UIX_SPEECH, __pSupportedLocaleList->Contains(locale), E_UNSUPPORTED_LOCALE, "This locale is not supported.");
437 *__pCurrentLocale = locale;
441 Tizen::Locales::Locale
442 _TextToSpeechImpl::GetLocale(void) const
444 SysTryReturn(NID_UIX_SPEECH, __isInitialized, Locale(LANGUAGE_INVALID, COUNTRY_INVALID), E_INVALID_STATE,
445 "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
447 SetLastResult(E_SUCCESS);
448 return *__pCurrentLocale;
451 const Tizen::Base::Collection::IList*
452 _TextToSpeechImpl::GetSupportedLocales(void) const
454 SysTryReturn(NID_UIX_SPEECH, __isInitialized, null, E_INVALID_STATE,
455 "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
457 SetLastResult(E_SUCCESS);
458 return __pSupportedLocaleList->GetCount() > 0 ? __pSupportedLocaleList : null;
462 _TextToSpeechImpl::IsLocaleSupported(const Tizen::Locales::Locale& locale) const
464 SysTryReturn(NID_UIX_SPEECH, __isInitialized, false, E_INVALID_STATE,
465 "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
467 SetLastResult(E_SUCCESS);
468 return __pSupportedLocaleList->Contains(locale);
472 _TextToSpeechImpl::SetSpeechRate(TextToSpeechSpeechRate speechRate)
474 SysTryReturnResult(NID_UIX_SPEECH, __isInitialized, E_INVALID_STATE,
475 "Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
477 __speechRate = speechRate;
483 _TextToSpeechImpl::GetCurrentStatus(void) const
485 SysTryReturn(NID_UIX_SPEECH, __isInitialized, TEXT_TO_SPEECH_STATUS_NONE, E_INVALID_STATE,
486 "[E_INVALID_STATE] Not yet initialized! This method should be called after receiving OnTextToSpeechInitialized() event.");
488 SetLastResult(E_SUCCESS);
489 return __currentStatus;
493 _TextToSpeechImpl::GetInstance(TextToSpeech& textToSpeech)
495 return textToSpeech.__pTextToSpeechImpl;
498 const _TextToSpeechImpl*
499 _TextToSpeechImpl::GetInstance(const TextToSpeech& textToSpeech)
501 return textToSpeech.__pTextToSpeechImpl;
505 _TextToSpeechImpl::GetEngineErrorMessage(const int errorType)
510 return "TTS_ERROR_NONE";
512 case TTS_ERROR_OUT_OF_MEMORY:
513 return "TTS_ERROR_OUT_OF_MEMORY";
515 case TTS_ERROR_IO_ERROR:
516 return "TTS_ERROR_IO_ERROR";
518 case TTS_ERROR_INVALID_PARAMETER:
519 return "TTS_ERROR_INVALID_PARAMETER";
521 case TTS_ERROR_INVALID_STATE:
522 return "TTS_ERROR_INVALID_STATE";
524 case TTS_ERROR_INVALID_VOICE:
525 return "TTS_ERROR_INVALID_VOICE";
527 case TTS_ERROR_ENGINE_NOT_FOUND:
528 return "TTS_ERROR_ENGINE_NOT_FOUND";
530 case TTS_ERROR_TIMED_OUT:
531 return "TTS_ERROR_TIMED_OUT";
533 case TTS_ERROR_OPERATION_FAILED:
534 return "TTS_ERROR_OPERATION_FAILED";
537 return "TTS_ERROR_UNKNOWN_ERROR";
542 _TextToSpeechImpl::GetEngineStateMessage(const tts_state_e state)
546 case TTS_STATE_CREATED:
549 case TTS_STATE_READY:
552 case TTS_STATE_PLAYING:
555 case TTS_STATE_PAUSED:
564 _TextToSpeechImpl::GetEngineVoiceTypeMessage(const tts_voice_type_e voiceType)
568 case TTS_VOICE_TYPE_AUTO:
569 return "TTS_VOICE_TYPE_AUTO";
571 case TTS_VOICE_TYPE_MALE:
572 return "TTS_VOICE_TYPE_MALE";
574 case TTS_VOICE_TYPE_FEMALE:
575 return "TTS_VOICE_TYPE_FEMALE";
577 case TTS_VOICE_TYPE_CHILD:
578 return "TTS_VOICE_TYPE_CHILD";
580 case TTS_VOICE_TYPE_USER1:
581 return "TTS_VOICE_TYPE_USER1";
583 case TTS_VOICE_TYPE_USER2:
584 return "TTS_VOICE_TYPE_USER2";
586 case TTS_VOICE_TYPE_USER3:
587 return "TTS_VOICE_TYPE_USER3";
590 return "TTS_VOICE_TYPE_UNKNOWN";
595 _TextToSpeechImpl::ConvertOspSpeedToEngine(const TextToSpeechSpeechRate& speechRate) const
599 case TEXT_TO_SPEECH_SPEECH_RATE_SYSTEM_SETTING:
600 return TTS_SPEED_AUTO;
602 case TEXT_TO_SPEECH_SPEECH_RATE_VERY_SLOW:
603 return TTS_SPEED_VERY_SLOW;
605 case TEXT_TO_SPEECH_SPEECH_RATE_SLOW:
606 return TTS_SPEED_SLOW;
608 case TEXT_TO_SPEECH_SPEECH_RATE_NORMAL:
609 return TTS_SPEED_NORMAL;
611 case TEXT_TO_SPEECH_SPEECH_RATE_FAST:
612 return TTS_SPEED_FAST;
614 case TEXT_TO_SPEECH_SPEECH_RATE_VERY_FAST:
615 return TTS_SPEED_VERY_FAST;
618 return TTS_SPEED_AUTO;
623 _TextToSpeechImpl::ConvertOspLocaleToEngineN(const Tizen::Locales::Locale& locale)
625 String strLanguageCode = Locale::LanguageCodeToTwoLetterLanguageCodeString(locale.GetLanguageCode());
626 String strCountryCode = Locale::CountryCodeToString(locale.GetCountryCode());
628 String strLanguage = strLanguageCode + L"_" + strCountryCode;
630 return _StringConverter::CopyToCharArrayN(strLanguage);
633 const Tizen::Locales::Locale*
634 _TextToSpeechImpl::ConvertEngineLocaleToOspN(const Tizen::Base::String& strSource)
636 String strDelim(L"_");
637 String strLanguageCode;
638 String strCountryCode;
640 LanguageCode languageCode = LANGUAGE_INVALID;
641 CountryCode countryCode = COUNTRY_INVALID;
643 Utility::StringTokenizer toknizer(strSource, strDelim);
644 if (toknizer.GetTokenCount() == 2)
646 toknizer.GetNextToken(strLanguageCode);
647 toknizer.GetNextToken(strCountryCode);
649 languageCode = Locale::TwoLetterLanguageCodeStringToLanguageCode(strLanguageCode);
650 countryCode = Locale::StringToCountryCode(strCountryCode);
653 return new (std::nothrow) Locale(languageCode, countryCode);
656 } } } // Tizen::Uix::Speech