• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 IINTELL_VOICE_ENGINE_H
17 #define IINTELL_VOICE_ENGINE_H
18 #include "iremote_broker.h"
19 
20 namespace OHOS {
21 namespace IntellVoiceEngine {
22 enum IntellVoiceEngineType {
23     INTELL_VOICE_ENROLL = 0,
24     INTELL_VOICE_WAKEUP,
25     INTELL_VOICE_UPDATE,
26     ENGINE_TYPE_BUT,
27     INTELL_VOICE_HEADSET_OFFSET = 200,
28     INTELL_VOICE_HEADSET_WAKEUP = INTELL_VOICE_HEADSET_OFFSET
29 };
30 
31 enum IntellVoiceUpdateSceneType {
32     INTELL_VOICE_DEFAULT = -1,
33     INTELL_VOICE_SILENCE_UPDATE = 0,
34     INTELL_VOICE_CLONE_UPDATE,
35     INTELL_VOICE_CLOUD_UPDATE,
36     INTELL_VOICE_SCENE_TYPE_BUT
37 };
38 
39 enum HeadsetHostEventType {
40     HEADSET_HOST_OFF = 0,
41     HEADSET_HOST_ON = 1,
42 };
43 
44 struct EvaluationResult {
45     int32_t score;
46     int32_t resultCode;
47 };
48 
49 struct IntellVoiceEngineInfo {
50     std::string wakeupPhrase;
51     bool isPcmFromExternal { false };
52     int32_t minBufSize { 0 };
53     int32_t sampleChannels { 0 };
54     int32_t bitsPerSample { 0 };
55     int32_t sampleRate { 0 };
56 };
57 
58 class IIntellVoiceEngine : public IRemoteBroker {
59 public:
60     DECLARE_INTERFACE_DESCRIPTOR(u"HDI.IntellVoice.Engine");
61 
62     enum {
63         INTELL_VOICE_ENGINE_SET_CALLBACK = 0,
64         INTELL_VOICE_ENGINE_ATTACH,
65         INTELL_VOICE_ENGINE_DETACH,
66         INTELL_VOICE_ENGINE_SET_PARAMETER,
67         INTELL_VOICE_ENGINE_GET_PARAMETER,
68         INTELL_VOICE_ENGINE_START,
69         INTELL_VOICE_ENGINE_STOP,
70         INTELL_VOICE_ENGINE_WRITE_AUDIO,
71         INTELL_VOICE_ENGINE_STAET_CAPTURER,
72         INTELL_VOICE_ENGINE_READ,
73         INTELL_VOICE_ENGINE_STOP_CAPTURER,
74         INTELL_VOICE_ENGINE_GET_WAKEUP_PCM,
75         INTELL_VOICE_ENGINE_EVALUATE,
76         INTELL_VOICE_ENGINE_NOTIFY_HEADSET_WAKE_EVENT,
77         INTELL_VOICE_ENGINE_NOTIFY_HEADSET_HOSTEVENT
78     };
79 
80     virtual void SetCallback(sptr<IRemoteObject> object) = 0;
81     virtual int32_t Attach(const IntellVoiceEngineInfo &info) = 0;
82     virtual int32_t Detach(void) = 0;
83     virtual int32_t SetParameter(const std::string &keyValueList) = 0;
84     virtual std::string GetParameter(const std::string &key) = 0;
85     virtual int32_t Start(bool isLast) = 0;
86     virtual int32_t Stop(void) = 0;
87     virtual int32_t WriteAudio(const uint8_t *buffer, uint32_t size) = 0;
88     virtual int32_t StartCapturer(int32_t channels) = 0;
89     virtual int32_t Read(std::vector<uint8_t> &data) = 0;
90     virtual int32_t StopCapturer() = 0;
91     virtual int32_t GetWakeupPcm(std::vector<uint8_t> &data) = 0;
92     virtual int32_t Evaluate(const std::string &word, EvaluationResult &result) = 0;
93     virtual int32_t NotifyHeadsetWakeEvent() = 0;
94     virtual int32_t NotifyHeadsetHostEvent(HeadsetHostEventType event) = 0;
95 };
96 }
97 }
98 
99 #endif
100