1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef INTELL_VOICE_UTILS_H
17 #define INTELL_VOICE_UTILS_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace IntellVoice {
23 enum ServiceChangeType {
24     /* Service unavailable. */
25     SERVICE_UNAVAILABLE = 0,
26 };
27 
28 enum IntelligentVoiceEngineType {
29     /* Enroll engine. */
30     ENROLL_ENGINE_TYPE = 0,
31     /* Wakeup engine. */
32     WAKEUP_ENGINE_TYPE = 1,
33     /* Update engine. */
34     UPDATE_ENGINE_TYPE = 2,
35 };
36 
37 enum SensibilityType {
38     /* Low sensibility. */
39     LOW_SENSIBILITY = 1,
40     /* Middle sensibility. */
41     MIDDLE_SENSIBILITY = 2,
42     /* High sensibility. */
43     HIGH_SENSIBILITY = 3,
44 };
45 
46 enum EnrollResult {
47     /* Enroll success. */
48     SUCCESS = 0,
49     /* Vpr train failed. */
50     VPR_TRAIN_FAILED = -1,
51     /* Wakeup phrase not match. */
52     WAKEUP_PHRASE_NOT_MATCH = -2,
53     /* Too noisy. */
54     TOO_NOISY = -3,
55     /* Too loud. */
56     TOO_LOUD = -4,
57     /* Interval large. */
58     INTERVAL_LARGE = -5,
59     /* Different person. */
60     DIFFERENT_PERSON = -6,
61     /* Unknown error. */
62     UNKNOWN_ERROR = -100,
63 };
64 
65 enum EnrollIntelligentVoiceEventType {
66     /* Enroll None. */
67     INTELLIGENT_VOICE_EVENT_ENROLL_NONE = 0,
68     /* Init done. */
69     INTELLIGENT_VOICE_EVENT_ENROLL_INIT_DONE = 1,
70     /* Enroll complete. */
71     INTELLIGENT_VOICE_EVENT_ENROLL_COMPLETE = 2,
72     /* Commit enroll complete. */
73     INTELLIGENT_VOICE_EVENT_COMMIT_ENROLL_COMPLETE = 3,
74 };
75 
76 enum WakeupIntelligentVoiceEventType {
77     /* Wakeup None. */
78     INTELLIGENT_VOICE_EVENT_WAKEUP_NONE = 0,
79     /* Recognize complete. */
80     INTELLIGENT_VOICE_EVENT_RECOGNIZE_COMPLETE = 1,
81     /* Headset Recognize complete. */
82     INTELLIGENT_VOICE_EVENT_HEADSET_RECOGNIZE_COMPLETE = 2,
83 };
84 
85 enum IntelligentVoiceErrorCode {
86     /* No memory. */
87     INTELLIGENT_VOICE_NO_MEMORY = 22700101,
88     /* Input parameter value error. */
89     INTELLIGENT_VOICE_INVALID_PARAM = 22700102,
90     /* Init failed. */
91     INTELLIGENT_VOICE_INIT_FAILED = 22700103,
92     /* Commit enroll failed. */
93     INTELLIGENT_VOICE_COMMIT_ENROLL_FAILED = 22700104,
94     /* Start capturer failed. */
95     INTELLIGENT_VOICE_START_CAPTURER_FAILED = 22700105,
96     /* Read failed. */
97     INTELLIGENT_VOICE_READ_FAILED = 22700106,
98     /* System error. */
99     INTELLIGENT_VOICE_SYSTEM_ERROR = 22700107,
100 };
101 
102 enum UploadFileType {
103     /* Enroll file. */
104     ENROLL_FILE = 0,
105     /* Wakeup file. */
106     WAKEUP_FILE = 1,
107 };
108 
109 enum EvaluationResultCode {
110     /* Unknown */
111     UNKNOWN = 0,
112     /* Pass */
113     PASS = 1,
114     /* Word is empty */
115     WORD_EMPTY = 2,
116     /* Only chinese is supported */
117     CHINESE_ONLY = 3,
118     /* Invalid length */
119     INVALID_LENGTH = 4,
120     /* Unusual word */
121     UNUSUAL_WORD = 5,
122     /* Consecutive same word */
123     CONSECUTIVE_SAME_WORD = 6,
124     /* Too few phonemes */
125     TOO_FEW_PHONEMES = 7,
126     /* Too many phoneme */
127     TOO_MANY_PHONEMES = 8,
128     /* Contain common instruction */
129     COMMON_INSTRUCTION = 9,
130     /* Contain common spoken language */
131     COMMON_SPOKEN_LANGUAGE = 10,
132     /* Contain sensitive word */
133     SENSITIVE_WORD = 11,
134     /* Two consecutive words without initial consonant */
135     NO_INITIAL_CONSONANT = 12,
136     /* Contain repeated phoneme */
137     REPEATED_PHONEME = 13,
138 };
139 
140 struct WakeupHapInfo {
141     std::string bundleName;
142     std::string abilityName;
143 };
144 
145 struct WakeupSourceFile {
146     std::string filePath;
147     std::vector<uint8_t> fileContent;
148 };
149 
150 }  // namespace IntellVoice
151 }  // namespace OHOS
152 #endif
153