[DEV] start analiser
This commit is contained in:
parent
0bd4847d2b
commit
2acaac5903
BIN
recoAnalyser/__pycache__/lutin_recoAnalyser.cpython-37.pyc
Normal file
BIN
recoAnalyser/__pycache__/lutin_recoAnalyser.cpython-37.pyc
Normal file
Binary file not shown.
13
recoAnalyser/appl/debug.cpp
Normal file
13
recoAnalyser/appl/debug.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2019, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("RecoWord");
|
||||
return g_val;
|
||||
}
|
39
recoAnalyser/appl/debug.hpp
Normal file
39
recoAnalyser/appl/debug.hpp
Normal file
@ -0,0 +1,39 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2019, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace appl {
|
||||
int32_t getLogId();
|
||||
}
|
||||
|
||||
#define APPL_BASE(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||
|
||||
#define APPL_PRINT(data) APPL_BASE(-1, data)
|
||||
#define APPL_CRITICAL(data) APPL_BASE(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASE(2, data)
|
||||
#define APPL_WARNING(data) APPL_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define APPL_INFO(data) APPL_BASE(4, data)
|
||||
#define APPL_DEBUG(data) APPL_BASE(5, data)
|
||||
#define APPL_VERBOSE(data) APPL_BASE(6, data)
|
||||
#define APPL_TODO(data) APPL_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define APPL_INFO(data) do { } while(false)
|
||||
#define APPL_DEBUG(data) do { } while(false)
|
||||
#define APPL_VERBOSE(data) do { } while(false)
|
||||
#define APPL_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define APPL_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
APPL_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
110
recoAnalyser/appl/main.cpp
Normal file
110
recoAnalyser/appl/main.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2019, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <etk/theme/theme.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
#include <audio/algo/speex/Resampler.hpp>
|
||||
|
||||
static int resampling_quality = 10; // speex resampler quality
|
||||
|
||||
/**
|
||||
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
etk::init(_argc, _argv);
|
||||
|
||||
|
||||
etk::Vector<etk::Uri> list = etk::uri::listRecursive("FILE:///framework/musicdsp/audio-reco-corpus/corpus1/");
|
||||
auto it = list.begin();
|
||||
while (it != list.end()) {
|
||||
if (it->getPath().getExtention() == "json") {
|
||||
++it;
|
||||
} else {
|
||||
it = list.erase(it);
|
||||
}
|
||||
}
|
||||
for (auto &it: list) {
|
||||
APPL_DEBUG("elem=" << it);
|
||||
ejson::Document doc;
|
||||
doc.load(it);
|
||||
etk::String fileName = doc["audio_filename"].toString().get();
|
||||
etk::Uri fileNameAudioFile = it;
|
||||
fileNameAudioFile.setPath(fileNameAudioFile.getPath().getParent() / fileName);
|
||||
etk::Uri fileNameAudioFile16k = it;
|
||||
fileNameAudioFile16k.setPath(fileNameAudioFile16k.getPath().getParent() / fileName + "_16k");
|
||||
APPL_DEBUG(" file=" << fileName);
|
||||
int32_t sampleRate = doc["audio_sample_rate"].toNumber().get();
|
||||
APPL_DEBUG(" sampleRate=" << sampleRate);
|
||||
etk::Vector<int16_t> dataBuffer;
|
||||
if (sampleRate != 16000) {
|
||||
if (etk::uri::exist(fileNameAudioFile16k) == false) {
|
||||
APPL_DEBUG(" *** LOAD_FILE ***");
|
||||
// read stream:
|
||||
etk::Vector<int16_t> bufferInput;
|
||||
{
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(fileNameAudioFile);
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
return -1;
|
||||
}
|
||||
bufferInput = fileIO->readAll<int16_t>();
|
||||
fileIO->close();
|
||||
}
|
||||
APPL_DEBUG(" *** RESAMPLE ***");
|
||||
dataBuffer.resize(bufferInput.size(), 0.0f);
|
||||
// Resample stream:
|
||||
audio::algo::speex::Resampler algo;
|
||||
algo.init(1, sampleRate, 16000, resampling_quality, audio::format_int16);
|
||||
size_t sizeOut = dataBuffer.size();
|
||||
/*
|
||||
for (int32_t iii=0; iii<1024; ++iii) {
|
||||
size_t sizeOut = output.size();
|
||||
algo.process(&output[0], sizeOut, &input[0], input.size());
|
||||
}
|
||||
*/
|
||||
algo.process(&dataBuffer[0], sizeOut, &bufferInput[0], bufferInput.size());
|
||||
dataBuffer.resize(sizeOut);
|
||||
APPL_DEBUG(" *** Store ***");
|
||||
{
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(fileNameAudioFile16k);
|
||||
if (fileIO->open(etk::io::OpenMode::Write) == false) {
|
||||
return -1;
|
||||
}
|
||||
fileIO->writeAll(dataBuffer);
|
||||
fileIO->close();
|
||||
}
|
||||
} else {
|
||||
APPL_DEBUG(" *** LOAD_FILE ***");
|
||||
// read stream: (We already have resample)
|
||||
{
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(fileNameAudioFile16k);
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
return -1;
|
||||
}
|
||||
dataBuffer = fileIO->readAll<int16_t>();
|
||||
fileIO->close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// the input file is already in 16k
|
||||
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(fileNameAudioFile);
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
return -1;
|
||||
}
|
||||
dataBuffer = fileIO->readAll<int16_t>();
|
||||
fileIO->close();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
44
recoAnalyser/lutin_recoAnalyser.py
Normal file
44
recoAnalyser/lutin_recoAnalyser.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import lutin.tools as tools
|
||||
import os
|
||||
|
||||
|
||||
def get_type():
|
||||
return "BINARY"
|
||||
|
||||
def get_desc():
|
||||
return "Simpleaudio IO viewer and test ..."
|
||||
|
||||
def get_licence():
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
def configure(target, my_module):
|
||||
my_module.add_extra_flags()
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/main.cpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'etk',
|
||||
'ejson',
|
||||
'audio-river',
|
||||
'audio-algo-speex',
|
||||
])
|
||||
my_module.add_path(".")
|
||||
# set the package properties :
|
||||
my_module.set_pkg("SECTION", ["Development"])
|
||||
my_module.set_pkg("PRIORITY", "optional")
|
||||
|
||||
my_module.add_pkg("RIGHT", "RECORD_AUDIO")
|
||||
return True
|
||||
|
Loading…
x
Reference in New Issue
Block a user