PocketSphinx  5.0.0
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  */
38 #ifndef __PS_VAD_H__
39 #define __PS_VAD_H__
40 
41 
42 #include <pocketsphinx/prim_type.h>
43 #include <pocketsphinx/export.h>
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 #if 0
49 }
50 #endif
51 
56 typedef struct ps_vad_s ps_vad_t;
57 
62 typedef enum ps_vad_mode_e {
63  PS_VAD_LOOSE = 0,
64  PS_VAD_MEDIUM_LOOSE = 1,
65  PS_VAD_MEDIUM_STRICT = 2,
66  PS_VAD_STRICT = 3
67 } ps_vad_mode_t;
68 
73 typedef enum ps_vad_class_e {
74  PS_VAD_ERROR = -1,
75  PS_VAD_NOT_SPEECH = 0,
76  PS_VAD_SPEECH = 1
77 } ps_vad_class_t;
78 
82 #define PS_VAD_DEFAULT_SAMPLE_RATE 16000
83 
86 #define PS_VAD_DEFAULT_FRAME_LENGTH 0.03
87 
105 POCKETSPHINX_EXPORT
106 ps_vad_t *ps_vad_init(ps_vad_mode_t mode, int sample_rate, double frame_length);
107 
115 POCKETSPHINX_EXPORT
117 
125 POCKETSPHINX_EXPORT
126 int ps_vad_free(ps_vad_t *vad);
127 
146 POCKETSPHINX_EXPORT
147 int ps_vad_set_input_params(ps_vad_t *vad, int sample_rate, double frame_length);
148 
156 POCKETSPHINX_EXPORT
157 int ps_vad_sample_rate(ps_vad_t *vad);
158 
170 POCKETSPHINX_EXPORT
171 size_t ps_vad_frame_size(ps_vad_t *vad);
172 
178 #define ps_vad_frame_length(vad) ((double)ps_vad_frame_size(vad) / ps_vad_sample_rate(vad))
179 
190 POCKETSPHINX_EXPORT
191 ps_vad_class_t ps_vad_classify(ps_vad_t *vad, const int16 *frame);
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* __PS_VAD_H__ */
prim_type.h
Basic type definitions used in Sphinx.
ps_vad_t::ps_vad_free
POCKETSPHINX_EXPORT int ps_vad_free(ps_vad_t *vad)
ps_vad_class_e
ps_vad_class_e
Classification of input frames returned by ps_vad_classify().
Definition: vad.h:73
ps_vad_t::ps_vad_init
POCKETSPHINX_EXPORT ps_vad_t * ps_vad_init(ps_vad_mode_t mode, int sample_rate, double frame_length)
ps_vad_t::ps_vad_frame_size
POCKETSPHINX_EXPORT size_t ps_vad_frame_size(ps_vad_t *vad)
ps_vad_mode_e
ps_vad_mode_e
Voice activity detection "aggressiveness" levels.
Definition: vad.h:62
ps_vad_t::ps_vad_classify
POCKETSPHINX_EXPORT ps_vad_class_t ps_vad_classify(ps_vad_t *vad, const int16 *frame)
ps_vad_t::ps_vad_sample_rate
POCKETSPHINX_EXPORT int ps_vad_sample_rate(ps_vad_t *vad)
ps_vad_t
Voice activity detector.
ps_vad_t::ps_vad_retain
POCKETSPHINX_EXPORT ps_vad_t * ps_vad_retain(ps_vad_t *vad)
ps_vad_t::ps_vad_set_input_params
POCKETSPHINX_EXPORT int ps_vad_set_input_params(ps_vad_t *vad, int sample_rate, double frame_length)