mirror of
https://github.com/espressif/esp-sr.git
synced 2025-09-15 15:28:44 +08:00
feature/update multinet2 for esp32s3beta
This commit is contained in:
parent
d289680270
commit
2a7aab136b
@ -22,10 +22,10 @@ target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/esp-tt
|
||||
target_link_libraries(${COMPONENT_TARGET} "-L ${CMAKE_CURRENT_SOURCE_DIR}/audio_front_end")
|
||||
|
||||
IF (IDF_VER MATCHES "v4.")
|
||||
add_prebuilt_library(multinet "${CMAKE_CURRENT_SOURCE_DIR}/lib/libmultinet.a" PRIV_REQUIRES esp-sr)
|
||||
add_prebuilt_library(esp_audio_processor "${CMAKE_CURRENT_SOURCE_DIR}/acoustic_algorithm/libesp_audio_processor.a" PRIV_REQUIRES esp-sr)
|
||||
add_prebuilt_library(wakenet "${CMAKE_CURRENT_SOURCE_DIR}/lib/libwakenet.a" PRIV_REQUIRES esp-sr)
|
||||
ENDIF (IDF_VER MATCHES "v4.")
|
||||
add_prebuilt_library(multinet "${CMAKE_CURRENT_SOURCE_DIR}/lib/libmultinet.a" PRIV_REQUIRES esp-sr)
|
||||
|
||||
if(IDF_TARGET STREQUAL "esp32")
|
||||
target_link_libraries(${COMPONENT_TARGET} "-Wl,--start-group"
|
||||
@ -66,10 +66,13 @@ endif()
|
||||
if(IDF_TARGET STREQUAL "esp32s3beta")
|
||||
target_link_libraries(${COMPONENT_TARGET} "-Wl,--start-group"
|
||||
wakenet
|
||||
esp-dsp
|
||||
dl_lib_esp32s3
|
||||
c_speech_features
|
||||
wakeword_model
|
||||
customized_word_wn5
|
||||
multinet_model
|
||||
esp_audio_front_end
|
||||
esp_audio_processor
|
||||
multinet
|
||||
"-Wl,--end-group")
|
||||
endif()
|
||||
|
||||
@ -1,87 +1,127 @@
|
||||
menu "ESP Speech Recognition"
|
||||
|
||||
choice NET_TO_USE_PRELOAD
|
||||
prompt "Net to use acceleration"
|
||||
default WAKENET_USE_PRELOAD
|
||||
depends on IDF_TARGET_ESP32S3BETA
|
||||
help
|
||||
Select the Wake Word Engine to be used.
|
||||
|
||||
config WAKENET_USE_PRELOAD
|
||||
bool "wakenet"
|
||||
|
||||
config MULTINET_USE_PRELOAD
|
||||
bool "multinet"
|
||||
|
||||
endchoice
|
||||
|
||||
choice SR_MODEL_SEL
|
||||
prompt "Wake word engine"
|
||||
default SR_MODEL_WN5_QUANT
|
||||
help
|
||||
Select the Wake Word Engine to be used.
|
||||
|
||||
config SR_MODEL_WN3_QUANT
|
||||
bool "WakeNet 3 (quantized)"
|
||||
|
||||
config SR_MODEL_WN4_QUANT
|
||||
bool "WakeNet 4 (quantized)"
|
||||
|
||||
config SR_MODEL_WN5_QUANT
|
||||
bool "WakeNet 5 (quantized)"
|
||||
bool "WakeNet 5 (quantized with 16-bit)"
|
||||
|
||||
config SR_MODEL_WN6_QUANT
|
||||
bool "WakeNet 6 (quantized)"
|
||||
config SR_MODEL_WN7_QUANT
|
||||
bool "WakeNet 7 (quantized with 16-bit)"
|
||||
|
||||
config SR_MODEL_WN7_QUANT8
|
||||
bool "WakeNet 7 (quantized with 8-bit)"
|
||||
|
||||
endchoice
|
||||
|
||||
|
||||
choice SR_WAKE_WORD_SEL
|
||||
prompt "Wake word name"
|
||||
default SR_WN5_HILEXIN
|
||||
help
|
||||
Select the wake word to be used.
|
||||
|
||||
config SR_WN3_HILEXIN
|
||||
bool "hilexin (WakeNet3)"
|
||||
depends on SR_MODEL_WN3_QUANT
|
||||
|
||||
config SR_WN4_HILEXIN
|
||||
bool "hilexin (WakeNet4)"
|
||||
depends on SR_MODEL_WN4_QUANT
|
||||
|
||||
config SR_WN5_HILEXIN
|
||||
bool "hilexin (WakeNet5)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5X2_HILEXIN
|
||||
bool "hilexin (WakeNet5X2)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5X3_HILEXIN
|
||||
bool "hilexin (WakeNet5X3)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5_NIHAOXIAOZHI
|
||||
bool "nihaoxiaozhi (WakeNet5)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5X2_NIHAOXIAOZHI
|
||||
bool "nihaoxiaozhi (WakeNet5X2)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5X3_NIHAOXIAOZHI
|
||||
bool "nihaoxiaozhi (WakeNet5X3)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5X3_HIJESON
|
||||
bool "hi jeson (WakeNet5X3)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5X3_NIHAOXIAOXIN
|
||||
bool "nihaoxiaoxin (WakeNet5X3)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN5_CUSTOMIZED_WORD
|
||||
bool "customized word (WakeNet5)"
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN5_FLOAT
|
||||
depends on SR_MODEL_WN5_QUANT
|
||||
|
||||
config SR_WN6_NIHAOXIAOXIN
|
||||
bool "nihaoxiaoxin (WakeNet6)"
|
||||
depends on SR_MODEL_WN6_QUANT
|
||||
config SR_WN7_CUSTOMIZED_WORD
|
||||
bool "customized word (WakeNet7)"
|
||||
depends on SR_MODEL_WN7_QUANT || SR_MODEL_WN7_QUANT8
|
||||
|
||||
config SR_WN6_CUSTOMIZED_WORD
|
||||
bool "customized word (WakeNet6)"
|
||||
depends on SR_MODEL_WN6_QUANT || SR_MODEL_WN6_FLOAT
|
||||
config SR_WN7_HILEXIN
|
||||
bool "hilexin (WakeNet7)"
|
||||
depends on SR_MODEL_WN7_QUANT || SR_MODEL_WN7_QUANT8
|
||||
|
||||
config SR_WN7_XIAOAITONGXUE
|
||||
bool "xiaoaitongxue (WakeNet7)"
|
||||
depends on SR_MODEL_WN7_QUANT || SR_MODEL_WN7_QUANT8
|
||||
|
||||
config SR_WN7_ALEXA
|
||||
bool "alexa (WakeNet7)"
|
||||
depends on SR_MODEL_WN7_QUANT || SR_MODEL_WN7_QUANT8
|
||||
|
||||
endchoice
|
||||
|
||||
|
||||
choice SR_MN_MODEL_SEL
|
||||
prompt "speech commands recognition model after wake up"
|
||||
default MULTINET1
|
||||
help
|
||||
Select the model to be used.
|
||||
|
||||
config MULTINET1
|
||||
depends on SR_MODEL_WN5_QUANT || SR_MODEL_WN6_QUANT
|
||||
bool "MultiNet 1"
|
||||
|
||||
config MULTINET2
|
||||
depends on SR_MODEL_WN7_QUANT || SR_MODEL_WN7_QUANT8
|
||||
bool "MultiNet 2"
|
||||
|
||||
config MULTINET3
|
||||
bool "MultiNet 3"
|
||||
|
||||
config MULTINET4
|
||||
bool "MultiNet 4"
|
||||
|
||||
config MULTINET5
|
||||
bool "MultiNet 5"
|
||||
|
||||
config MULTINET6
|
||||
bool "MultiNet 6"
|
||||
|
||||
endchoice
|
||||
|
||||
choice SR_MN_MODE_SEL
|
||||
prompt "speech commands recognition mode after wake up"
|
||||
default SINGLE_RECOGNITION
|
||||
help
|
||||
@ -96,7 +136,7 @@ config CONTINUOUS_RECOGNITION
|
||||
endchoice
|
||||
|
||||
choice SR_LANGUAGE_SEL
|
||||
prompt "language"
|
||||
prompt "langugae"
|
||||
default SR_CHINESE
|
||||
help
|
||||
Select the language to be used.
|
||||
|
||||
@ -36,7 +36,7 @@ typedef esp_afe_sr_data_t* (*esp_afe_sr_iface_op_create_t)(afe_sr_mode_t mode, i
|
||||
* @param afe The AFE_SR object to query
|
||||
* @return The amount of samples to feed the fetch function
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_get_frame_chunksize_t)(esp_afe_sr_data_t *afe);
|
||||
typedef int (*esp_afe_sr_iface_op_get_samp_chunksize_t)(esp_afe_sr_data_t *afe);
|
||||
|
||||
/**
|
||||
* @brief Get the channel number of samples that need to be passed to the fetch function
|
||||
@ -62,7 +62,7 @@ typedef int (*esp_afe_sr_iface_op_get_samp_rate_t)(esp_afe_sr_data_t *afe);
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @param in The input microphone signal, only support signed 16-bit @ 16 KHZ. The frame size can be queried by the
|
||||
* `get_frame_chunksize`. The channel number can be queried `get_channel_num`.
|
||||
* `get_samp_chunksize`. The channel number can be queried `get_channel_num`.
|
||||
* @return The size of input
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_feed_t)(esp_afe_sr_data_t *afe, const int16_t* in);
|
||||
@ -73,7 +73,7 @@ typedef int (*esp_afe_sr_iface_op_feed_t)(esp_afe_sr_data_t *afe, const int16_t*
|
||||
* @Warning The output is single channel data, no matter how many channels the input is.
|
||||
*
|
||||
* @param afe The AFE_SR object to query
|
||||
* @param out The output enhanced signal. The frame size can be queried by the `get_frame_chunksize`.
|
||||
* @param out The output enhanced signal. The frame size can be queried by the `get_samp_chunksize`.
|
||||
* @return The style of output, -1: noise, 0: speech, 1: wake word 1, 2: wake word 2, ...
|
||||
*/
|
||||
typedef int (*esp_afe_sr_iface_op_fetch_t)(esp_afe_sr_data_t *afe, int16_t* out);
|
||||
@ -138,7 +138,7 @@ typedef struct {
|
||||
esp_afe_sr_iface_op_create_t create;
|
||||
esp_afe_sr_iface_op_feed_t feed;
|
||||
esp_afe_sr_iface_op_fetch_t fetch;
|
||||
esp_afe_sr_iface_op_get_frame_chunksize_t get_frame_chunksize;
|
||||
esp_afe_sr_iface_op_get_samp_chunksize_t get_samp_chunksize;
|
||||
esp_afe_sr_iface_op_get_channel_num_t get_channel_num;
|
||||
esp_afe_sr_iface_op_get_samp_rate_t get_samp_rate;
|
||||
esp_afe_sr_iface_op_set_wakenet_t set_wakenet;
|
||||
|
||||
Binary file not shown.
221
lib/include/dl_lib_convq8_queue.h
Normal file
221
lib/include/dl_lib_convq8_queue.h
Normal file
@ -0,0 +1,221 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef DL_LIB_CONVQ8_QUEUE_H
|
||||
#define DL_LIB_CONVQ8_QUEUE_H
|
||||
|
||||
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
#include "dl_lib_conv_queue.h"
|
||||
#include "dl_lib_convq_queue.h"
|
||||
|
||||
typedef struct {
|
||||
int n; /*< the length of queue */
|
||||
int c; /*< the channel number of queue element*/
|
||||
int front; /*< the front(top) position of queue */
|
||||
int flag; /*< not used */
|
||||
int exponent; /*< The values in items should be multiplied by pow(2,exponent)
|
||||
to get the real values */
|
||||
q8tp_t *itemq; /*< Pointer to item array */
|
||||
} dl_convq8_queue_t;
|
||||
|
||||
/**
|
||||
* @brief Allocate a fixed-point convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The channel number of elements in the queue
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq8_queue_t *dl_convq8_queue_alloc(int n, int c);
|
||||
|
||||
/**
|
||||
* @brief Free a fixed-point convolution queue
|
||||
*
|
||||
* @param cq The fixed-point convolution queue to free
|
||||
*/
|
||||
void dl_convq8_queue_free(dl_convq8_queue_t *cq);
|
||||
|
||||
/**
|
||||
* @brief Insert the float-point element at the end of queue.
|
||||
* The precision of fixed-point numbers is described by the Qm.f notation,
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param item The float-point element
|
||||
* @param m_bit The number of integer bits including the sign bits
|
||||
* @param f_bit The number of fractional bits
|
||||
*/
|
||||
void dl_convq8_queue_push_by_qmf(dl_convq8_queue_t *cq, fptp_t* item, int m_bit, int f_bit);
|
||||
|
||||
/**
|
||||
* @brief Get the pointer of element in the queue by offset
|
||||
*
|
||||
* @param cq Input fixed-point convolution queue
|
||||
* @param offset Offset from the front of the queue
|
||||
* @return Pointer of the element
|
||||
*/
|
||||
q8tp_t *dl_get_queue_itemq8(dl_convq8_queue_t *cq, int offset);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised implement for 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel Kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param out_exponent Shift ratio used in dot operation between two 16-bit fixed point vector
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
* @return The result of atrous convolution
|
||||
*/
|
||||
void dl_atrous_conv1dq8_steps(dl_convq8_queue_t *in, dl_convq8_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq8_t* kernel, dl_matrix2dq8_t* bias,
|
||||
int out_exponent, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of dilation layer as follows
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input fixed-point convolution queue
|
||||
* @param out Output fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
* @return The result of dilation layer
|
||||
*/
|
||||
void dl_dilation_layerq8_steps(dl_convq8_queue_t *in, dl_convq8_queue_t *out, int rate, int size,
|
||||
dl_matrix2dq8_t* filter_kernel, dl_matrix2dq8_t* filter_bias,
|
||||
dl_matrix2dq8_t* gate_kernel, dl_matrix2dq8_t* gate_bias,
|
||||
int offset, int prenum);
|
||||
|
||||
|
||||
|
||||
|
||||
dl_conv_queue_t *dl_convq8_queue_add(dl_convq8_queue_t *cq1, dl_convq8_queue_t *cq2);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate a 8-bit fixed-point Multi-Channel convolution queue
|
||||
*
|
||||
* @param n The length of queue
|
||||
* @param c The number of elements in the queue
|
||||
* @param nch The channel number
|
||||
* @return The convolution queue, or NULL if out of memory
|
||||
*/
|
||||
dl_convq8_queue_t **dl_convq8_queue_mc_alloc(int n, int c, int nch);
|
||||
|
||||
/**
|
||||
* @brief Free a 8-bit fixed-point Multi-Channel convolution queue
|
||||
*
|
||||
* @param cqm The fixed-point convolution queue to free
|
||||
* @param nch The channel number
|
||||
*/
|
||||
void dl_convq8_queue_mc_free(dl_convq8_queue_t **cqm, int nch);
|
||||
|
||||
/**
|
||||
* @brief Tanh activation function for 8-bit fixed-point Multi-Channel convolution queue input
|
||||
*
|
||||
* @param cqm Input 8-bit fixed-point Multi-Channel convolution queue
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param nch The channel number
|
||||
*/
|
||||
void dl_tanh_convq8_mc(dl_convq8_queue_t **cqm, int offset, int nch);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised 16-bit implement for Multi-channel 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* Usually, this layer is used as first layer for 8-bit network.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* Input is a 16-bit queue point, Output is an 8-bit queue point.
|
||||
*
|
||||
* @param in Input 16bit fixed-point convolution queue array
|
||||
* @param out Output 8bit fixed-point convolution queue array
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param out_exponent Exponent of output
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
*/
|
||||
void dl_atrous_conv1dq8_16in_mc_steps(dl_convq_queue_t **in, dl_convq8_queue_t **out, int nch, int rate, int size,
|
||||
dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int out_exponent, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast and quantised 8-bit implement for Multi-channel 1D atrous convolution (a.k.a. convolution with holes or dilated convolution)
|
||||
* based on convolution queue.
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input 8bit fixed-point convolution queue array
|
||||
* @param out Output 8bit fixed-point convolution queue array
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param kernel The kernel matrix of filter
|
||||
* @param bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param out_exponent Exponent of output
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
*/
|
||||
void dl_atrous_conv1dq8_mc_steps(dl_convq8_queue_t **in, dl_convq8_queue_t **out,
|
||||
int nch, int rate, int size,
|
||||
dl_matrix2dq8_t* kernel, dl_matrix2dq8_t* bias,
|
||||
int out_exponent, int offset, int prenum);
|
||||
|
||||
/**
|
||||
* @brief Fast implement of 8-bit dilation layer as follows
|
||||
*
|
||||
* |-> [gate(sigmoid)] -|
|
||||
* input - | |-> (*) - output
|
||||
* |-> [filter(tanh)] -|
|
||||
*
|
||||
* @Warning All input and output convolution queue and matrix should be allocated. The return pointer
|
||||
* is last element of output queue and should not be freed separately.
|
||||
*
|
||||
* @param in Input 8-bit fixed-point convolution queue
|
||||
* @param out Output 8-bit fixed-point convolution queue
|
||||
* @param rate A positive int, the stride with which we sample input value
|
||||
* @param size A positive int, the size of 1D-filter
|
||||
* @param filter_kernel The kernel matrix of filter
|
||||
* @param filter_bias The bias matrix of filter. Can be NULL if a bias of 0 is required.
|
||||
* @param gate_kernel The kernel matrix of gate
|
||||
* @param gate_bias The bias matrix of gate. Can be NULL if a bias of 0 is required.
|
||||
* @param offset Offset used to calculate the beginning of input conv queue
|
||||
* @param prenum The num to control the parameter size of preload operation
|
||||
*/
|
||||
void dl_dilation_layerq8_mc_steps(dl_convq8_queue_t **in, dl_convq8_queue_t **out, int nch, int rate, int size,
|
||||
dl_matrix2dq8_t* filter_kernel, dl_matrix2dq8_t* filter_bias,
|
||||
dl_matrix2dq8_t* gate_kernel, dl_matrix2dq8_t* gate_bias,
|
||||
int offset, int prenum);
|
||||
|
||||
void print_convq8(dl_convq8_queue_t *cq, int offset);
|
||||
void print_convq(dl_convq_queue_t *cq, int offset);
|
||||
#endif
|
||||
60
lib/include/dl_lib_matrixq8.h
Normal file
60
lib/include/dl_lib_matrixq8.h
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#ifndef DL_LIB_MATRIXQ8_H
|
||||
#define DL_LIB_MATRIXQ8_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "dl_lib_matrix.h"
|
||||
|
||||
typedef int8_t q8tp_t;
|
||||
|
||||
typedef struct {
|
||||
int w;
|
||||
int h;
|
||||
int stride; //Normally equals h, not w!
|
||||
int flags;
|
||||
int exponent; //The values in items should be multiplied by pow(2,exponent) to get the real values.
|
||||
q8tp_t *itemq;
|
||||
} dl_matrix2dq8_t;
|
||||
|
||||
#define DL_Q8TP_SHIFT 7
|
||||
#define DL_Q8TP_RANGE ((1<<DL_Q8TP_SHIFT)-1)
|
||||
#define DL_ITMQ8(m, x, y) m->itemq[(y)+(x)*m->stride]
|
||||
|
||||
/**
|
||||
* @brief Allocate a matrix
|
||||
*
|
||||
* @param w Width of the matrix
|
||||
* @param h Height of the matrix
|
||||
* @return The matrix, or NULL if out of memory
|
||||
*/
|
||||
dl_matrix2dq8_t *dl_matrixq8_alloc(int w, int h);
|
||||
|
||||
/**
|
||||
* @brief Free a quantized matrix
|
||||
* Frees the matrix structure and (if it doesn't have the DL_MF_FOREIGNDATA flag set) the m->items space as well.
|
||||
*
|
||||
* @param m Matrix to free
|
||||
*/
|
||||
void dl_matrixq8_free(dl_matrix2dq8_t *m);
|
||||
/**
|
||||
* @brief Convert a floating-point matrix to a quantized matrix
|
||||
*
|
||||
* @param m Floating-point matrix to convert
|
||||
* @param out Quantized matrix to re-use. If NULL, allocate a new one.
|
||||
* @Return The quantized version of the floating-point matrix
|
||||
*/
|
||||
dl_matrix2dq8_t *dl_matrixq8_from_matrix2d(const dl_matrix2d_t *m, dl_matrix2dq8_t *out);
|
||||
|
||||
#endif
|
||||
Binary file not shown.
BIN
lib/libesp-dsp.a
Normal file
BIN
lib/libesp-dsp.a
Normal file
Binary file not shown.
Binary file not shown.
BIN
lib/libwakenet.a
BIN
lib/libwakenet.a
Binary file not shown.
@ -76,6 +76,7 @@ typedef void (*esp_mn_iface_op_destroy_t)(model_iface_data_t *model);
|
||||
*/
|
||||
typedef void (*esp_mn_iface_op_reset_t)(void);
|
||||
|
||||
|
||||
typedef struct {
|
||||
esp_mn_iface_op_create_t create;
|
||||
esp_mn_iface_op_get_samp_rate_t get_samp_rate;
|
||||
|
||||
@ -3,34 +3,30 @@
|
||||
|
||||
//Contains declarations of all available speech recognion models. Pair this up with the right coefficients and you have a model that can recognize
|
||||
//a specific phrase or word.
|
||||
extern const esp_mn_iface_t esp_sr_multinet1_quantized_cn;
|
||||
extern const esp_mn_iface_t esp_sr_multinet1_quantized_en;
|
||||
extern const esp_mn_iface_t esp_sr_multinet2_quantized_cn;
|
||||
/*
|
||||
Configure network to use based on what's selected in menuconfig.
|
||||
*/
|
||||
// #if CONFIG_SINGLE_RECOGNITION
|
||||
// #define MULTINET_MODEL esp_sr_multinet1_quantized
|
||||
// #else
|
||||
// #error No valid neural network model selected.
|
||||
// #endif
|
||||
|
||||
extern const esp_mn_iface_t esp_sr_multinet1_single_quantized_cn;
|
||||
extern const esp_mn_iface_t esp_sr_multinet1_continuous_quantized_cn;
|
||||
extern const esp_mn_iface_t esp_sr_multinet1_single_quantized_en;
|
||||
extern const esp_mn_iface_t esp_sr_multinet2_single_quantized_cn;
|
||||
|
||||
/*
|
||||
Configure wake word to use based on what's selected in menuconfig.
|
||||
*/
|
||||
#if CONFIG_SR_CHINESE && CONFIG_SINGLE_RECOGNITION
|
||||
#if CONFIG_MULTINET1 && CONFIG_SR_CHINESE && CONFIG_SINGLE_RECOGNITION
|
||||
#include "multinet1_ch.h"
|
||||
#define MULTINET_MODEL esp_sr_multinet1_quantized_cn
|
||||
#define MULTINET_MODEL esp_sr_multinet1_single_quantized_cn
|
||||
#define MULTINET_COEFF get_coeff_multinet1_ch
|
||||
#elif CONFIG_SR_ENGLISH && CONFIG_SINGLE_RECOGNITION
|
||||
#elif CONFIG_MULTINET1 && CONFIG_SR_CHINESE && CONFIG_CONTINUOUS_RECOGNITION
|
||||
#include "multinet1_ch.h"
|
||||
#define MULTINET_MODEL esp_sr_multinet1_continuous_quantized_cn
|
||||
#define MULTINET_COEFF get_coeff_multinet1_ch
|
||||
#elif CONFIG_MULTINET1 && CONFIG_SR_ENGLISH && CONFIG_SINGLE_RECOGNITION
|
||||
#include "multinet1_en.h"
|
||||
#define MULTINET_MODEL esp_sr_multinet1_quantized_en
|
||||
#define MULTINET_MODEL esp_sr_multinet1_single_quantized_en
|
||||
#define MULTINET_COEFF get_coeff_multinet1_en
|
||||
#elif CONFIG_SR_CHINESE && CONFIG_CONTINUOUS_RECOGNITION
|
||||
#include "multinet1_ch.h"
|
||||
#define MULTINET_MODEL esp_sr_multinet2_quantized_cn
|
||||
#define MULTINET_COEFF get_coeff_multinet1_ch
|
||||
#elif CONFIG_MULTINET2 && CONFIG_SR_CHINESE && CONFIG_SINGLE_RECOGNITION
|
||||
#include "multinet2_ch.h"
|
||||
#define MULTINET_MODEL esp_sr_multinet2_single_quantized_cn
|
||||
#define MULTINET_COEFF get_coeff_multinet2_ch
|
||||
#else
|
||||
#error No valid wake word selected.
|
||||
#endif
|
||||
|
||||
9
speech_command_recognition/include/multinet2_ch.h
Normal file
9
speech_command_recognition/include/multinet2_ch.h
Normal file
@ -0,0 +1,9 @@
|
||||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_multinet2_ch;
|
||||
BIN
speech_command_recognition/libmultinet_model.a
Normal file
BIN
speech_command_recognition/libmultinet_model.a
Normal file
Binary file not shown.
9
wake_word_engine/include/customized_word_wn7.h
Normal file
9
wake_word_engine/include/customized_word_wn7.h
Normal file
@ -0,0 +1,9 @@
|
||||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_customized_word_wn7;
|
||||
9
wake_word_engine/include/hilexin_wn7.h
Normal file
9
wake_word_engine/include/hilexin_wn7.h
Normal file
@ -0,0 +1,9 @@
|
||||
//Generated by mkmodel_py
|
||||
#pragma once
|
||||
#include <string.h>
|
||||
#include "dl_lib_coefgetter_if.h"
|
||||
#include "dl_lib_matrix.h"
|
||||
#include "dl_lib_matrixq.h"
|
||||
#include "dl_lib_matrixq8.h"
|
||||
|
||||
extern const model_coeff_getter_t get_coeff_hilexin_wn7;
|
||||
Loading…
Reference in New Issue
Block a user