Tizen 2.1 base
[framework/osp/speech.git] / src / stt / FUixSpeech_SpeechToTextImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file    FUixSpeech_SpeechToTextImpl.h
20  * @brief   This is the header file for the %_SpeechToTextImpl class.
21  *
22  * This header file contains the declarations of the %_SpeechToTextImpl class.
23  */
24
25 #ifndef _FUIX_SPEECH_INTERNAL_SPEECH_TO_TEXT_IMPL_H_
26 #define _FUIX_SPEECH_INTERNAL_SPEECH_TO_TEXT_IMPL_H_
27
28 #include <stt.h>
29 #include <FBaseDataType.h>
30 #include <FBaseObject.h>
31 #include <FOspConfig.h>
32 #include <FUixSpeechSpeechToTextTypes.h>
33 #include <FUixSpeechISpeechToTextEventListener.h>
34
35 namespace Tizen { namespace Base
36 {
37     class String;
38 }}
39 namespace Tizen { namespace Base { namespace Collection
40 {
41     class IList;
42 }}}
43 namespace Tizen { namespace Locales
44 {
45     class Locale;
46 }}
47
48 namespace Tizen { namespace Uix { namespace Speech
49 {
50
51 class SpeechToText;
52
53 class _SpeechToTextImpl
54 {
55 public:
56     _SpeechToTextImpl(void);
57     virtual ~_SpeechToTextImpl(void);
58
59     result Construct(ISpeechToTextEventListener& listener);
60     result Initialize(void);
61
62     result Start(void);
63     result Stop(void);
64     result Cancel(void);
65
66     result SetLocale(const Tizen::Locales::Locale& locale);
67     Tizen::Locales::Locale GetLocale(void) const;
68     bool IsLocaleSupported(const Tizen::Locales::Locale& locale) const;
69     const Tizen::Base::Collection::IList* GetSupportedLocales(void) const;
70
71     result SetGrammar(SpeechToTextGrammar grammar);
72     SpeechToTextGrammar GetGrammar(void) const;
73
74     result SetSilenceDetectionEnabled(bool enable);
75     bool IsSilenceDetectionEnabled(void) const;
76
77     SpeechToTextStatus GetCurrentStatus(void) const;
78
79     static _SpeechToTextImpl* GetInstance(SpeechToText& speechToText);
80     static const _SpeechToTextImpl* GetInstance(const SpeechToText& speechToText);
81
82 private:
83     _SpeechToTextImpl(const _SpeechToTextImpl& rhs);
84     _SpeechToTextImpl& operator =(const _SpeechToTextImpl& rhs);
85
86     static void SttResultReceiver(stt_h sttHandle, const char* type, const char* data[], int dataCount, const char* msg, void* pListener);
87     static void SttPartialResultReceiver(stt_h sttHandle, const char* data, void* pListener);
88     static void SttStateChangedReceiver(stt_h sttHandle, stt_state_e previousState, stt_state_e currentState, void* pSttInstance);
89     static void SttErrorReceiver(stt_h sttHandle, stt_error_e error, void* pListener);
90     static bool SttSupportedLocaleListGetter(stt_h sttHandle, const char* language, void* pLocaleList);
91
92     static const char* GetEngineErrorMessage(const int type);
93     static const char* GetEngineStateMessage(const stt_state_e state);
94
95     static const Tizen::Locales::Locale* ConvertEngineLocaleToOspN(const Tizen::Base::String& strSource);
96     static const char* ConvertOspLocaleToEngineN(const Tizen::Locales::Locale& locale);
97
98     static const char* ConvertOspRecognitionTypeToEngine(SpeechToTextGrammar grammar);
99
100     stt_option_silence_detection_e ConvertOspSilenceDetectionTypeToEngine(bool silenceDetectionType);
101
102 private:
103     stt_h __sttHandle;
104     ISpeechToTextEventListener* __pSpeechToTextListener;
105
106     Tizen::Locales::Locale* __pCurrentLocale;
107     SpeechToTextGrammar __grammar;
108     Tizen::Base::Collection::IList* __pSupportedLocaleList;
109
110     bool __isInitialized;
111     bool __isSilenceDetection;
112     SpeechToTextStatus __currentStatus;
113
114 }; // _SpeechToTextImpl
115
116 } } } // Tizen::Uix::Speech
117
118 #endif