From 4b04365f3fd93b5f25da9e9f56667c8a90623310 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 1 Apr 2019 22:09:41 +0200 Subject: [PATCH] [DEV] add a simple VAD with speex library --- audio/algo/speex/Resampler.cpp | 4 +- audio/algo/speex/Vad.cpp | 114 +++++++++++++++++++++++++++++++++ audio/algo/speex/Vad.hpp | 64 ++++++++++++++++++ lutin_audio-algo-speex.py | 9 ++- 4 files changed, 187 insertions(+), 4 deletions(-) create mode 100644 audio/algo/speex/Vad.cpp create mode 100644 audio/algo/speex/Vad.hpp diff --git a/audio/algo/speex/Resampler.cpp b/audio/algo/speex/Resampler.cpp index 10eacfb..5a72c4d 100644 --- a/audio/algo/speex/Resampler.cpp +++ b/audio/algo/speex/Resampler.cpp @@ -78,6 +78,7 @@ namespace audio { break; case audio::format_float: { + AA_SPEEX_ERROR("RESAMPLE: " << _nbChunk << " ==> " << _nbChunkOut); uint32_t nbChunkInput = _nbChunk; uint32_t nbChunkOutput = _nbChunkOut; int ret = speex_resampler_process_interleaved_float(m_speexResampler, @@ -85,6 +86,7 @@ namespace audio { &nbChunkInput, reinterpret_cast(_output), &nbChunkOutput); + AA_SPEEX_ERROR("RESAMPLE: " << nbChunkInput << " ==> " << nbChunkOutput << " DONE"); // Check all input and output ... if (nbChunkInput != _nbChunk) { AA_SPEEX_ERROR("inputSize (not all read ...) proceed=" << nbChunkInput << " requested=" << _nbChunk); @@ -132,7 +134,7 @@ etk::Vector audio::algo::speex::Resampler::getSupportedForma etk::Vector audio::algo::speex::Resampler::getNativeSupportedFormat() { etk::Vector out; - out.pushBack(audio::format_float); + //out.pushBack(audio::format_float); ==> sppex dsp only compille in fixpoint, of float ... not at the same time ... out.pushBack(audio::format_int16); return out; } diff --git a/audio/algo/speex/Vad.cpp b/audio/algo/speex/Vad.cpp new file mode 100644 index 0000000..d21bfde --- /dev/null +++ b/audio/algo/speex/Vad.cpp @@ -0,0 +1,114 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2011, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +#define speex_POSIX 1 +#include