porcupine_recognizer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021, Rein Appeldoorn
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 
18 #pragma once
19 
20 #include <map>
21 #include <ostream>
22 #include <picovoice.h>
23 #include <pv_porcupine.h>
24 #include <string>
25 #include <vector>
26 
27 #include "./recognizer.h"
28 
29 namespace picovoice_driver
30 {
32 {
34  {
38  std::map<std::string, std::string> keywords_;
39 
43  double sensitivity_ = 0.5;
44  };
45 
46  struct Result
47  {
51  bool is_understood_ = false;
52 
56  std::string keyword_name_;
57  };
58 };
59 std::ostream& operator<<(std::ostream& os, const PorcupineRecognizerData::Parameters& p);
60 std::ostream& operator<<(std::ostream& os, const PorcupineRecognizerData::Result& r);
61 
62 class PorcupineRecognizer : public RecognizerT<PorcupineRecognizerData>
63 {
64 public:
66 
67  void configure(const PorcupineRecognizerData::Parameters& parameters) override;
69 
70 private:
72  void recognizeInit() override;
73 
74  bool recognizeProcess(int16_t* frames) override;
75 
76  std::vector<std::string> keyword_names_;
77  std::vector<const char*> keyword_paths_;
78  std::vector<float> keyword_sensitivities_;
79 
82 };
83 } // namespace picovoice_driver
picovoice_driver::RecognizerT
Definition: recognizer.h:101
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
picovoice_driver::PorcupineRecognizer::porcupine_
pv_porcupine_t * porcupine_
Definition: porcupine_recognizer.h:81
picovoice_driver::operator<<
std::ostream & operator<<(std::ostream &os, const PorcupineRecognizerData::Parameters &p)
Definition: porcupine_recognizer.cpp:25
picovoice_driver::PorcupineRecognizer::getRecordSettings
RecordSettings getRecordSettings() override
Definition: porcupine_recognizer.cpp:73
picovoice_driver::PorcupineRecognizer::~PorcupineRecognizer
~PorcupineRecognizer()
Definition: porcupine_recognizer.cpp:38
picovoice_driver::PorcupineRecognizer::keyword_names_
std::vector< std::string > keyword_names_
Definition: porcupine_recognizer.h:76
recognizer.h
picovoice_driver::PorcupineRecognizer
Definition: porcupine_recognizer.h:62
picovoice_driver::PorcupineRecognizer::recognizeProcess
bool recognizeProcess(int16_t *frames) override
Definition: porcupine_recognizer.cpp:86
picovoice_driver::PorcupineRecognizer::getResult
PorcupineRecognizerData::Result getResult() override
getResult Get the recognition result
Definition: porcupine_recognizer.cpp:68
picovoice_driver::PorcupineRecognizer::result_
PorcupineRecognizerData::Result result_
Definition: porcupine_recognizer.h:80
picovoice_driver::PorcupineRecognizer::keyword_paths_
std::vector< const char * > keyword_paths_
Definition: porcupine_recognizer.h:77
picovoice_driver::PorcupineRecognizer::keyword_sensitivities_
std::vector< float > keyword_sensitivities_
Definition: porcupine_recognizer.h:78
picovoice_driver
Definition: porcupine_node.cpp:24
picovoice_driver::PorcupineRecognizerData::Parameters
Definition: porcupine_recognizer.h:33
pv_porcupine_t
struct pv_porcupine pv_porcupine_t
Definition: include/pv_porcupine.h:33
picovoice_driver::PorcupineRecognizerData::Parameters::keywords_
std::map< std::string, std::string > keywords_
keywords_ Map from a keyword names to a keyword.ppn paths
Definition: porcupine_recognizer.h:38
picovoice_driver::PorcupineRecognizer::configure
void configure(const PorcupineRecognizerData::Parameters &parameters) override
Definition: porcupine_recognizer.cpp:46
picovoice_driver::PorcupineRecognizerData::Parameters::sensitivity_
double sensitivity_
sensitivity_ Recognizer sensitivity
Definition: porcupine_recognizer.h:43
picovoice_driver::Recognizer::RecordSettings
Definition: recognizer.h:77
picovoice_driver::PorcupineRecognizerData::Result::is_understood_
bool is_understood_
is_understood_ Whether the recognizer understood a keyword
Definition: porcupine_recognizer.h:51
picovoice_driver::RecognizerData::Parameters
Definition: recognizer.h:28
picovoice_driver::PorcupineRecognizerData::Result::keyword_name_
std::string keyword_name_
keyword_name_ Detected keyword name
Definition: porcupine_recognizer.h:56
picovoice_driver::PorcupineRecognizerData
Definition: porcupine_recognizer.h:31
picovoice_driver::PorcupineRecognizer::recognizeInit
void recognizeInit() override
Definition: porcupine_recognizer.cpp:81
picovoice_driver::PorcupineRecognizerData::Result
Definition: porcupine_recognizer.h:46


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:50