PocketSphinx 5.1.0
A small speech recognizer
Loading...
Searching...
No Matches
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
43#include <pocketsphinx/export.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48#if 0
49}
50#endif
51
56typedef struct ps_vad_s ps_vad_t;
57
62typedef 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
73typedef 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
86#define PS_VAD_DEFAULT_FRAME_LENGTH 0.03
87
105POCKETSPHINX_EXPORT
106ps_vad_t *ps_vad_init(ps_vad_mode_t mode, int sample_rate, double frame_length);
107
115POCKETSPHINX_EXPORT
117
125POCKETSPHINX_EXPORT
127
146POCKETSPHINX_EXPORT
147int ps_vad_set_input_params(ps_vad_t *vad, int sample_rate, double frame_length);
148
156POCKETSPHINX_EXPORT
158
170POCKETSPHINX_EXPORT
172
178#define ps_vad_frame_length(vad) ((double)ps_vad_frame_size(vad) / ps_vad_sample_rate(vad))
179
190POCKETSPHINX_EXPORT
191ps_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__ */
Basic type definitions used in Sphinx.
Voice activity detector.
POCKETSPHINX_EXPORT int ps_vad_sample_rate(ps_vad_t *vad)
POCKETSPHINX_EXPORT ps_vad_t * ps_vad_init(ps_vad_mode_t mode, int sample_rate, double frame_length)
POCKETSPHINX_EXPORT int ps_vad_set_input_params(ps_vad_t *vad, int sample_rate, double frame_length)
POCKETSPHINX_EXPORT ps_vad_t * ps_vad_retain(ps_vad_t *vad)
POCKETSPHINX_EXPORT ps_vad_class_t ps_vad_classify(ps_vad_t *vad, const int16 *frame)
POCKETSPHINX_EXPORT size_t ps_vad_frame_size(ps_vad_t *vad)
POCKETSPHINX_EXPORT int ps_vad_free(ps_vad_t *vad)
ps_vad_mode_e
Voice activity detection "aggressiveness" levels.
Definition vad.h:62
ps_vad_class_e
Classification of input frames returned by ps_vad_classify().
Definition vad.h:73