add code.
This commit is contained in:
parent
7a2dbca39e
commit
28db31167c
@ -1,5 +1,4 @@
|
||||
#include "IoContext.h"
|
||||
// #include "RKAP_3A.h"
|
||||
#include "SpeexDsp.h"
|
||||
#include "WebRtcAecm.h"
|
||||
#include "api/audio/echo_canceller3_config.h"
|
||||
@ -52,15 +51,24 @@ void ProcessFileTask::setDsp(Dsp dsp) {
|
||||
}
|
||||
}
|
||||
|
||||
// ./build/Record/Record --file --dsp=aecm
|
||||
// ./Record --file --dsp=aecm
|
||||
void ProcessFileTask::run() {
|
||||
m_speakerIfs = std::make_shared<std::ifstream>("/sdcard/speaker_16k.pcm", std::ifstream::binary);
|
||||
m_micIfs = std::make_shared<std::ifstream>("/sdcard/micin_16k.pcm", std::ifstream::binary);
|
||||
#ifdef __RV1109__
|
||||
constexpr auto MicFile = "/sdcard/micin_16k.pcm";
|
||||
constexpr auto SpeakerFile = "/sdcard/speaker_16k.pcm";
|
||||
|
||||
#else
|
||||
constexpr auto MicFile = "resources/micin_16k.pcm";
|
||||
constexpr auto SpeakerFile = "resources/speaker_16k.pcm";
|
||||
#endif
|
||||
m_speakerIfs = std::make_shared<std::ifstream>(SpeakerFile, std::ifstream::binary);
|
||||
m_micIfs = std::make_shared<std::ifstream>(MicFile, std::ifstream::binary);
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << DumpPath << "/out_" << dspToString(m_dsp) << "_16k.pcm";
|
||||
oss << DumpPath << "/out_" << dspToString(m_dsp) << "_16k.wav";
|
||||
m_outFilename = oss.str();
|
||||
m_ofs = std::make_shared<std::ofstream>(m_outFilename, std::ofstream::binary);
|
||||
m_ofs = std::make_shared<WavWriter<int16_t>>(m_outFilename, 1, 16000);
|
||||
|
||||
oss.str("");
|
||||
oss << DumpPath << "/ns_" << dspToString(m_dsp) << "_16k.pcm";
|
||||
@ -130,6 +138,6 @@ void ProcessFileTask::process() {
|
||||
} else {
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - m_begin);
|
||||
LOG(info) << "process file finished, out: " << m_outFilename << ", elapsed: " << elapsed;
|
||||
std::exit(0);
|
||||
ioConext->stop();
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
#include "RkAudio.h"
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include "WavWriter.h"
|
||||
|
||||
class SpeexDsp;
|
||||
class WebRtcAecm;
|
||||
@ -15,7 +16,11 @@ enum Dsp {
|
||||
Aec3,
|
||||
};
|
||||
|
||||
#ifdef __RV1109__
|
||||
constexpr auto DumpPath = "/sdcard/data";
|
||||
#else
|
||||
constexpr auto DumpPath = "./build/data";
|
||||
#endif
|
||||
|
||||
class Task {
|
||||
public:
|
||||
@ -95,7 +100,7 @@ private:
|
||||
std::shared_ptr<WebRtcAecm> m_webRtcAecm;
|
||||
std::shared_ptr<std::ifstream> m_speakerIfs;
|
||||
std::shared_ptr<std::ifstream> m_micIfs;
|
||||
std::shared_ptr<std::ofstream> m_ofs;
|
||||
std::shared_ptr<WavWriter<int16_t>> m_ofs;
|
||||
std::shared_ptr<std::ofstream> m_nsOfs; // 降噪后的文件
|
||||
std::string m_outFilename;
|
||||
std::chrono::system_clock::time_point m_begin;
|
||||
|
BIN
resources/micin_16k.pcm
Normal file
BIN
resources/micin_16k.pcm
Normal file
Binary file not shown.
BIN
resources/speaker_16k.pcm
Normal file
BIN
resources/speaker_16k.pcm
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user