PocketSphinx  5.0.0rc5
A small speech recognizer
vad.h
Go to the documentation of this file.
1 /* -*- c-basic-offset:4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 2022 David Huggins-Daines. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27  * OF THE POSSIBILITY OF SUCH DAMAGE.
28  * ====================================================================
29  */
35 #ifndef __PS_VAD_H__
36 #define __PS_VAD_H__
37 
38 
39 #include <pocketsphinx/prim_type.h>
40 #include <pocketsphinx/export.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 #if 0
46 }
47 #endif
48 
52 typedef struct ps_vad_s ps_vad_t;
53 
57 typedef enum ps_vad_mode_e {
58  PS_VAD_LOOSE = 0,
59  PS_VAD_MEDIUM_LOOSE = 1,
60  PS_VAD_MEDIUM_STRICT = 2,
61  PS_VAD_STRICT = 3
63 
67 typedef enum ps_vad_class_e {
68  PS_VAD_ERROR = -1,
69  PS_VAD_NOT_SPEECH = 0,
70  PS_VAD_SPEECH = 1
72 
76 #define PS_VAD_DEFAULT_SAMPLE_RATE 16000
77 
80 #define PS_VAD_DEFAULT_FRAME_LENGTH 0.03
81 
98 POCKETSPHINX_EXPORT
99 ps_vad_t *ps_vad_init(ps_vad_mode_t mode, int sample_rate, double frame_length);
100 
107 POCKETSPHINX_EXPORT
109 
116 POCKETSPHINX_EXPORT
117 int ps_vad_free(ps_vad_t *vad);
118 
136 POCKETSPHINX_EXPORT
137 int ps_vad_set_input_params(ps_vad_t *vad, int sample_rate, double frame_length);
138 
145 POCKETSPHINX_EXPORT
146 int ps_vad_sample_rate(ps_vad_t *vad);
147 
158 POCKETSPHINX_EXPORT
159 size_t ps_vad_frame_size(ps_vad_t *vad);
160 
166 #define ps_vad_frame_length(vad) ((double)ps_vad_frame_size(vad) / ps_vad_sample_rate(vad))
167 
177 POCKETSPHINX_EXPORT
178 ps_vad_class_t ps_vad_classify(ps_vad_t *vad, const int16 *frame);
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* __PS_VAD_H__ */
prim_type.h
Basic type definitions used in Sphinx.
ps_vad_retain
POCKETSPHINX_EXPORT ps_vad_t * ps_vad_retain(ps_vad_t *vad)
ps_vad_init
POCKETSPHINX_EXPORT ps_vad_t * ps_vad_init(ps_vad_mode_t mode, int sample_rate, double frame_length)
ps_vad_class_e
ps_vad_class_e
Definition: vad.h:67
ps_vad_classify
POCKETSPHINX_EXPORT ps_vad_class_t ps_vad_classify(ps_vad_t *vad, const int16 *frame)
ps_vad_frame_size
POCKETSPHINX_EXPORT size_t ps_vad_frame_size(ps_vad_t *vad)
ps_vad_set_input_params
POCKETSPHINX_EXPORT int ps_vad_set_input_params(ps_vad_t *vad, int sample_rate, double frame_length)
ps_vad_class_t
enum ps_vad_class_e ps_vad_class_t
ps_vad_free
POCKETSPHINX_EXPORT int ps_vad_free(ps_vad_t *vad)
ps_vad_t
struct ps_vad_s ps_vad_t
Definition: vad.h:52
ps_vad_mode_e
ps_vad_mode_e
Definition: vad.h:57
ps_vad_sample_rate
POCKETSPHINX_EXPORT int ps_vad_sample_rate(ps_vad_t *vad)
ps_vad_mode_t
enum ps_vad_mode_e ps_vad_mode_t