1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 12 /* 13 * This header file includes the VAD API calls. Specific function calls are given below. 14 */ 15 16 #ifndef WEBRTC_VAD_WEBRTC_VAD_H_ 17 #define WEBRTC_VAD_WEBRTC_VAD_H_ 18 19 #include "typedefs.h" 20 21 typedef struct WebRtcVadInst VadInst; 22 23 #ifdef __cplusplus 24 extern "C" 25 { 26 #endif 27 28 /**************************************************************************** 29 * WebRtcVad_get_version(...) 30 * 31 * This function returns the version number of the code. 32 * 33 * Output: 34 * - version : Pointer to a buffer where the version info will 35 * be stored. 36 * Input: 37 * - size_bytes : Size of the buffer. 38 * 39 */ 40 WebRtc_Word16 WebRtcVad_get_version(char *version, size_t size_bytes); 41 42 /**************************************************************************** 43 * WebRtcVad_AssignSize(...) 44 * 45 * This functions get the size needed for storing the instance for encoder 46 * and decoder, respectively 47 * 48 * Input/Output: 49 * - size_in_bytes : Pointer to integer where the size is returned 50 * 51 * Return value : 0 52 */ 53 WebRtc_Word16 WebRtcVad_AssignSize(int *size_in_bytes); 54 55 /**************************************************************************** 56 * WebRtcVad_Assign(...) 57 * 58 * This functions Assigns memory for the instances. 59 * 60 * Input: 61 * - vad_inst_addr : Address to where to assign memory 62 * Output: 63 * - vad_inst : Pointer to the instance that should be created 64 * 65 * Return value : 0 - Ok 66 * -1 - Error 67 */ 68 WebRtc_Word16 WebRtcVad_Assign(VadInst **vad_inst, void *vad_inst_addr); 69 70 /**************************************************************************** 71 * WebRtcVad_Create(...) 72 * 73 * This function creates an instance to the VAD structure 74 * 75 * Input: 76 * - vad_inst : Pointer to VAD instance that should be created 77 * 78 * Output: 79 * - vad_inst : Pointer to created VAD instance 80 * 81 * Return value : 0 - Ok 82 * -1 - Error 83 */ 84 WebRtc_Word16 WebRtcVad_Create(VadInst **vad_inst); 85 86 /**************************************************************************** 87 * WebRtcVad_Free(...) 88 * 89 * This function frees the dynamic memory of a specified VAD instance 90 * 91 * Input: 92 * - vad_inst : Pointer to VAD instance that should be freed 93 * 94 * Return value : 0 - Ok 95 * -1 - Error 96 */ 97 WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst); 98 99 /**************************************************************************** 100 * WebRtcVad_Init(...) 101 * 102 * This function initializes a VAD instance 103 * 104 * Input: 105 * - vad_inst : Instance that should be initialized 106 * 107 * Output: 108 * - vad_inst : Initialized instance 109 * 110 * Return value : 0 - Ok 111 * -1 - Error 112 */ 113 WebRtc_Word16 WebRtcVad_Init(VadInst *vad_inst); 114 115 /**************************************************************************** 116 * WebRtcVad_set_mode(...) 117 * 118 * This function initializes a VAD instance 119 * 120 * Input: 121 * - vad_inst : VAD instance 122 * - mode : Aggressiveness setting (0, 1, 2, or 3) 123 * 124 * Output: 125 * - vad_inst : Initialized instance 126 * 127 * Return value : 0 - Ok 128 * -1 - Error 129 */ 130 WebRtc_Word16 WebRtcVad_set_mode(VadInst *vad_inst, WebRtc_Word16 mode); 131 132 /**************************************************************************** 133 * WebRtcVad_Process(...) 134 * 135 * This functions does a VAD for the inserted speech frame 136 * 137 * Input 138 * - vad_inst : VAD Instance. Needs to be initiated before call. 139 * - fs : sampling frequency (Hz): 8000, 16000, or 32000 140 * - speech_frame : Pointer to speech frame buffer 141 * - frame_length : Length of speech frame buffer in number of samples 142 * 143 * Output: 144 * - vad_inst : Updated VAD instance 145 * 146 * Return value : 1 - Active Voice 147 * 0 - Non-active Voice 148 * -1 - Error 149 */ 150 WebRtc_Word16 WebRtcVad_Process(VadInst *vad_inst, 151 WebRtc_Word16 fs, 152 WebRtc_Word16 *speech_frame, 153 WebRtc_Word16 frame_length); 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159 #endif // WEBRTC_VAD_WEBRTC_VAD_H_ 160