我根据堆栈溢出上的这个example创建了代码的MFCC提取部分,它创建了两个AudioProcessor实例。但是,使用Android上的调试器,我发现代码快速地进入了processingFinished函数,同时它跳过了这两个函数的进程函数。实例中的mfcc变量在第二个AudioProcessor函数的processingFinished函数中为空。为什么数据从来不处理?这是获得MFCC的正确方法吗?
我的源代码:(我将theAudioDispatcher从文件改为管道)
private void onMFCC() {
int sampleRate = 44100;
int bufferSize = 1024;
int bufferOverlap = 128;
//final AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050,1024,512);
String path = getExternalCacheDir().getAbsolutePath() + "/saytest.mp4";
new AndroidFFMPEGLocator(this);
final AudioDispatcher dispatcher = AudioDispatcherFactory.fromPipe(path, sampleRate, bufferSize, bufferOverlap);
final MFCC mfcc = new MFCC(bufferSize, sampleRate, 40, 50, 300, 3000);
dispatcher.addAudioProcessor(mfcc);
dispatcher.addAudioProcessor(new AudioProcessor() {
@Override
public void processingFinished() {
//vvv error b/c mfcc instance variable is null
//float[] mfccArr = mfcc.getMFCC();
System.out.println("DONE");
}
@Override
public boolean process(AudioEvent audioEvent) {
// breakpoint or logging to console doesn't enter function
return true;
}
});
dispatcher.run();
}是否有可能是由于管道AudioDispatcher导致的错误与此有关?
Starting piped decoding process for /storage/emulated/0/Android/data/com.example.audiorecorder/cache/saytest.mp4
I/PipeDecoder: with command: "/data/user/0/com.example.audiorecorder/cache/ffmpeg" -ss 0.0 -i "/storage/emulated/0/Android/data/com.example.audiorecorder/cache/saytest.mp4" -vn -ar 44100 -ac 1 -sample_fmt s16 -f s16le pipe:1
I/PipeDecoder: CANNOT LINK EXECUTABLE "/data/user/0/com.example.audiorecorder/cache/ffmpeg": /data/data/com.example.audiorecorder/cache/ffmpeg: has text relocations
I/PipeDecoder: Aborted
I/PipeDecoder: Finished piped decoding process任何帮助都将不胜感激。非常感谢!
编辑:--我尝试通过将这一行添加到方法的末尾来独立调用process函数:
mfcc.process(new AudioEvent(new TarsosDSPAudioFormat(sampleRate, bufferSize, 1, true, true)));然而,这给了我一个NullPointerException。
发布于 2017-07-17 21:45:51
我修复了这个问题,因为我意识到调度程序fromPipe不工作,所以我替换了调度程序:
InputStream inStream = new FileInputStream(path);
AudioDispatcher dispatcher = new AudioDispatcher(new UniversalAudioInputStream(inStream, new TarsosDSPAudioFormat(sampleRate, bufferSize, 1, true, true)), bufferSize, bufferOverlap);https://stackoverflow.com/questions/45043466
复制相似问题