NUGU SDK Linux  1.7.6
speech_recognizer_interface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 SK Telecom Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #ifndef __NUGU_SPEECH_RECOGNIZER_INTERFACE_H__
18 #define __NUGU_SPEECH_RECOGNIZER_INTERFACE_H__
19 
20 #include <string>
21 
22 #include <nugu.h>
23 
24 namespace NuguClientKit {
25 
40 enum class ListeningState {
41  READY,
42  LISTENING,
43  SPEECH_START,
44  SPEECH_END,
45  TIMEOUT,
46  FAILED,
47  DONE
48 };
49 
53 typedef struct _EpdAttribute {
58 
63 class NUGU_API ISpeechRecognizerListener {
64 public:
65  virtual ~ISpeechRecognizerListener() = default;
66 
72  virtual void onListeningState(ListeningState state, const std::string& id) = 0;
73 
80  virtual void onRecordData(unsigned char* buf, int length, bool is_end) = 0;
81 };
82 
87 class NUGU_API ISpeechRecognizer {
88 public:
89  virtual ~ISpeechRecognizer() = default;
90 
95  virtual void setListener(ISpeechRecognizerListener* listener) = 0;
96 
102  virtual bool startListening(const std::string& id) = 0;
103 
107  virtual void stopListening() = 0;
108 
112  virtual void finishListening() = 0;
113 
118  virtual void setEpdAttribute(const EpdAttribute& attribute) = 0;
119 
125 
130  virtual bool isMute() = 0;
131 
136  virtual std::string getCodec() = 0;
137 
142  virtual std::string getMimeType() = 0;
143 };
144 
149 } // NuguClientKit
150 
151 #endif /* __NUGU_SPEECH_RECOGNIZER_INTERFACE_H__*/
SpeechRecognizer listener interface.
Definition: speech_recognizer_interface.hh:63
virtual void onRecordData(unsigned char *buf, int length, bool is_end)=0
Get current audio input stream.
virtual void onListeningState(ListeningState state, const std::string &id)=0
Report to the user listening state changed.
SpeechRecognizer interface.
Definition: speech_recognizer_interface.hh:87
virtual void finishListening()=0
finish listening speech
virtual void setListener(ISpeechRecognizerListener *listener)=0
Set SpeechRecognizer listener object.
virtual void setEpdAttribute(const EpdAttribute &attribute)=0
Set EPD attribute.
virtual void stopListening()=0
Stop listening speech.
virtual bool startListening(const std::string &id)=0
Start listening speech.
virtual std::string getCodec()=0
Get codec information of recorder.
virtual bool isMute()=0
Get audio recorder's mute.
virtual std::string getMimeType()=0
Get mime type information of recorder.
virtual EpdAttribute getEpdAttribute()=0
Get EPD attribute.
struct NuguClientKit::_EpdAttribute EpdAttribute
Attributes about epd.
ListeningState
ListeningState.
Definition: speech_recognizer_interface.hh:40
Attributes about epd.
Definition: speech_recognizer_interface.hh:53
long epd_pause_length
Definition: speech_recognizer_interface.hh:56
int epd_max_duration
Definition: speech_recognizer_interface.hh:55
int epd_timeout
Definition: speech_recognizer_interface.hh:54