[DEV] better display

This commit is contained in:
Edouard DUPIN 2019-01-16 23:11:58 +01:00
parent 8aa90d71d7
commit 96ed89d782
4 changed files with 106 additions and 6 deletions

View File

@ -13,9 +13,37 @@
#include <etk/theme/theme.hpp>
#include <ejson/ejson.hpp>
#include <audio/algo/speex/Resampler.hpp>
#include <audio/algo/speex/Vad.hpp>
static int resampling_quality = 10; // speex resampler quality
static void usage() {
APPL_PRINT(" --corpus_root_path=XXX Root path of the corpus (add after a folder with the name and other informations");
APPL_PRINT(" --corpus_output_path=XXX DESTINATION of the data");
exit(0);
}
/*
class InputData {
public:
etk::Vector<int16_t> stream;
ejson::Doc property;
};
InputData readInput(const etk::Uri& _uri) {
InputData out;
out.property.load(_uri);
etk::String fileName = out.property["audio_filename"].toString().get();
etk::Uri fileNameAudioFile = it;
fileNameAudioFile.setPath(fileNameAudioFile.getPath().getParent() / fileName);
return out;
}
ejson::Doc readConfig(const etk::Uri& _uri) {
}
*/
/**
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
* @param std IO
@ -23,9 +51,28 @@ static int resampling_quality = 10; // speex resampler quality
*/
int main(int _argc, const char *_argv[]) {
etk::init(_argc, _argv);
etk::Vector<etk::String> cmdLine;
for(int32_t iii=1 ; iii<_argc; iii++) {
cmdLine.pushBack(_argv[iii]);
}
etk::String corpusPath;
etk::String corpusOutput;
for(auto &it: cmdLine) {
etk::String tmpppp = it;
if ( tmpppp == "-h"
|| tmpppp == "--help") {
usage();
} else if (tmpppp.startWith("--corpus_root_path=") == true) {
corpusPath = tmpppp.extract(19);;
} else if (tmpppp.startWith("--corpus_output_path=") == true) {
corpusOutput = tmpppp.extract(21);;
} else {
APPL_ERROR("Unknow parameter: '" << tmpppp << "'" );
//usage();
}
}
etk::Vector<etk::Uri> list = etk::uri::listRecursive("FILE:///framework/musicdsp/audio-reco-corpus/corpus1/");
etk::Vector<etk::Uri> list = etk::uri::listRecursive("FILE:///framework/musicdsp/audio-reco-corpus-french/corpus_2019_DupinEdouard_1983/");
auto it = list.begin();
while (it != list.end()) {
if (it->getPath().getExtention() == "json") {
@ -38,11 +85,16 @@ int main(int _argc, const char *_argv[]) {
APPL_DEBUG("elem=" << it);
ejson::Document doc;
doc.load(it);
/////////////////////////////////////////////////////
/// LOAD and convert in 16k if needed:
/////////////////////////////////////////////////////
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");
etk::Uri fileNameAudioFileVAD = it;
fileNameAudioFileVAD.setPath(fileNameAudioFileVAD.getPath().getParent() / fileName + "_VAD");
APPL_DEBUG(" file=" << fileName);
int32_t sampleRate = doc["audio_sample_rate"].toNumber().get();
APPL_DEBUG(" sampleRate=" << sampleRate);
@ -85,7 +137,7 @@ int main(int _argc, const char *_argv[]) {
}
} else {
APPL_DEBUG(" *** LOAD_FILE ***");
// read stream: (We already have resample)
// read stream: (We already have resampled)
{
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(fileNameAudioFile16k);
if (fileIO->open(etk::io::OpenMode::Read) == false) {
@ -104,6 +156,56 @@ int main(int _argc, const char *_argv[]) {
dataBuffer = fileIO->readAll<int16_t>();
fileIO->close();
}
//marque loom
/////////////////////////////////////////////////////
/// Generate the VAD output:
/////////////////////////////////////////////////////
etk::Vector<int16_t> vadBuffer;
{
audio::algo::speex::Vad algo;
algo.init(1, 16000, audio::format_int16);
int16_t out[1024];
int16_t feedback[1024];
memset(feedback, 0, 2048);
for (int32_t iii=0; iii<dataBuffer.size()/32; ++iii) {
algo.process(out, &dataBuffer[iii*32], feedback, 32);
for (int32_t jjj=0; jjj<32; ++jjj) {
vadBuffer.pushBack(algo.getVoiceDetected()?32000:0);
}
}
}
APPL_DEBUG(" *** Store VAD *** [BEGIN]");
{
ememory::SharedPtr<etk::io::Interface> fileIO = etk::uri::get(fileNameAudioFileVAD);
if (fileIO->open(etk::io::OpenMode::Write) == false) {
return -1;
}
fileIO->writeAll(vadBuffer);
fileIO->close();
}
APPL_DEBUG(" *** Store VAD *** [ END ]");
/////////////////////////////////////////////////////
/// Remove unneeded data (clip all unneeded data
/// before and after the usable signal):
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
/// Generate the FFT:
/////////////////////////////////////////////////////
/////////////////////////////////////////////////////
/// Generate the CEPSTRE:
/////////////////////////////////////////////////////
}
return 0;

View File

@ -15,7 +15,7 @@ Natural Language Processing (NLP): https://github.com/zalandoresearch/flair
ideas of architeture:
=====================
![objectuve work](work.svg)
![objectuve work](work.jpg)

BIN
work.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 849 KiB