2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-23 12:36:46 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This header file includes the VAD API calls. Specific function calls are
|
|
|
|
|
* given below.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_ // NOLINT
|
|
|
|
|
#define COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
#include <stddef.h>
|
2018-07-25 16:05:48 +02:00
|
|
|
#include <stdint.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
typedef struct WebRtcVadInst VadInst;
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2012-03-12 12:17:26 +00:00
|
|
|
extern "C" {
|
2011-07-07 08:21:25 +00:00
|
|
|
#endif
|
|
|
|
|
|
2012-01-31 14:42:50 +00:00
|
|
|
// Creates an instance to the VAD structure.
|
2018-03-19 16:23:48 +01:00
|
|
|
VadInst* WebRtcVad_Create(void);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-01-31 14:42:50 +00:00
|
|
|
// Frees the dynamic memory of a specified VAD instance.
|
|
|
|
|
//
|
|
|
|
|
// - handle [i] : Pointer to VAD instance that should be freed.
|
2014-04-22 04:45:35 +00:00
|
|
|
void WebRtcVad_Free(VadInst* handle);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-03-12 12:17:26 +00:00
|
|
|
// Initializes a VAD instance.
|
|
|
|
|
//
|
|
|
|
|
// - handle [i/o] : Instance that should be initialized.
|
|
|
|
|
//
|
|
|
|
|
// returns : 0 - (OK),
|
2017-02-26 04:18:12 -08:00
|
|
|
// -1 - (null pointer or Default mode could not be set).
|
2012-03-12 12:17:26 +00:00
|
|
|
int WebRtcVad_Init(VadInst* handle);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2012-03-27 11:06:29 +00:00
|
|
|
// Sets the VAD operating mode. A more aggressive (higher mode) VAD is more
|
|
|
|
|
// restrictive in reporting speech. Put in other words the probability of being
|
|
|
|
|
// speech when the VAD returns 1 is increased with increasing mode. As a
|
|
|
|
|
// consequence also the missed detection rate goes up.
|
|
|
|
|
//
|
|
|
|
|
// - handle [i/o] : VAD instance.
|
|
|
|
|
// - mode [i] : Aggressiveness mode (0, 1, 2, or 3).
|
|
|
|
|
//
|
|
|
|
|
// returns : 0 - (OK),
|
2017-02-26 04:18:12 -08:00
|
|
|
// -1 - (null pointer, mode could not be set or the VAD instance
|
2012-03-27 11:06:29 +00:00
|
|
|
// has not been initialized).
|
|
|
|
|
int WebRtcVad_set_mode(VadInst* handle, int mode);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2021-07-26 12:15:29 +02:00
|
|
|
// Calculates a VAD decision for the `audio_frame`. For valid sampling rates
|
2012-06-12 08:19:24 +00:00
|
|
|
// frame lengths, see the description of WebRtcVad_ValidRatesAndFrameLengths().
|
|
|
|
|
//
|
|
|
|
|
// - handle [i/o] : VAD Instance. Needs to be initialized by
|
|
|
|
|
// WebRtcVad_Init() before call.
|
|
|
|
|
// - fs [i] : Sampling frequency (Hz): 8000, 16000, or 32000
|
|
|
|
|
// - audio_frame [i] : Audio frame buffer.
|
|
|
|
|
// - frame_length [i] : Length of audio frame buffer in number of samples.
|
|
|
|
|
//
|
|
|
|
|
// returns : 1 - (Active Voice),
|
|
|
|
|
// 0 - (Non-active Voice),
|
|
|
|
|
// -1 - (Error)
|
2014-04-30 16:44:13 +00:00
|
|
|
int WebRtcVad_Process(VadInst* handle,
|
|
|
|
|
int fs,
|
|
|
|
|
const int16_t* audio_frame,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t frame_length);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2021-07-26 12:15:29 +02:00
|
|
|
// Checks for valid combinations of `rate` and `frame_length`. We support 10,
|
2012-06-12 08:19:24 +00:00
|
|
|
// 20 and 30 ms frames and the rates 8000, 16000 and 32000 Hz.
|
|
|
|
|
//
|
|
|
|
|
// - rate [i] : Sampling frequency (Hz).
|
|
|
|
|
// - frame_length [i] : Speech frame buffer length in number of samples.
|
|
|
|
|
//
|
|
|
|
|
// returns : 0 - (valid combination), -1 - (invalid combination)
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int WebRtcVad_ValidRateAndFrameLength(int rate, size_t frame_length);
|
2012-06-12 08:19:24 +00:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // COMMON_AUDIO_VAD_INCLUDE_WEBRTC_VAD_H_ // NOLINT
|