我尝试使用Meyda提取音频文件的特性。但是,当使用命令行meyda和通过javascript文件提取时,特征提取值是不同的
-
命令行
meyda 1600153162.63571.wav mfcc
结果
0.057628476337413304,0.025103534166687494、-0.0033402018588145435、-0.00050914619032203364、-0.005969043107840086、-0.0094239628697326、-0.007781823184730455、-0.002403016732702066、-0.0033368248853514206、-0.001272591871309979,0.00003587458387239886,0.002937354749062950.0003162315327070361.4306079393227265、1.3713938566968262、0.2306487569743767、1.0515807610571597、0.8414768385049735、.6060415036630535、0.37326507523088365、0.1654296077992904、0.015392187854876595、0.16525095936577213、0.27571446879975764、0.340564139593766、-0.3650538438926707039.282664122642018、6.880236029290547、.3870794551074606、1.7170683624244123、-0.9657914336587826、-318544774959499、4.433789386396694、3.7101490665746217、2.816738558429225、2.2736417577176273、-1.636438686466657、-0.537746809738949、-0.5116460308902115225.65632094501052,22.93621824737729,16.08611763344924,7.490656903754756,-0.358888007314062,-5.64156791337735,-7.229285832273481,-5.63856022395436,2.1681330598896817,1.5575050036371694,4.296381195632149,5.45750656573637,5.05996621856976823.469876801827922,20.984500104582974,15.80549272827184,10.064116650359527,3.957435073588796,1.75506262168123,5.904087102697238,8.29320895086182,9.037630914839253,8.230609293960022,6.6041597934477832,4.8505887091085365-3.23906727518617529.1420600661076625.50517483703385,19.279159148659456,13.806566615476791,7.715092034538,2.2364700767576764,0.8129542016331001,2.16772108652068,2.6257181917727093,2.1347711722007845,1.0689231846996041,0.6059541306434987,-0.9955565080584865112.251538716256618,9.479093353756676,5.2726325506769,2.7893618666871762,0.10288164291841367,3.121859159330943,4.446188894370852,3.5959072906303837,2.5699522942015007,1.8300687753240275,0.7140618177046422,0.3644613187160053,0.835318506508760418.42772721964866,15.9904592445750096,11.9931328734504,9.088259023158539,.1723551883886699,2.6632784721745213,-0.683186290158647,1.948275236251193,2.793271841187546,3.305172382572076,3.6707865100252994,3.6389999985131219,-2.86326382282771515.915610973257571,13.737073178518493,9.801934620786648,5.779403187264773,1.358952752885622,-2.50841159816647,-5.187471901991046,-7.033404192058985,-7.737140523422115,-7.437282553994893,-6.058991955183858,-4.36024675428363,-2.68062980539606615.75090683856979,13.4970898998444463,9.489154494388005,5.57883842168272,1.4567586737610156,2.141429668615224,-4380728646793593,5.364310654901947,5.049848052960211,4.214979808517224,3.9745754014376224,4.076571890925421,-4.02071430360983423.361729244701564,20.83103985201436,16.592090051349242,12.885538444506535,8.373777248668826,2.9768227085972145,-1399644048138661,-4.0944050595665753,5.574775136428788,-5.787457864519816,-4.693018758118676,-3100993535744204,-1.562554637739947512.793707716744393,10.197116076581045,5.819041457288568,2.4679725003955064,-0.3304198215142393,-2.607817847380143,-4.086110143731154,-4.79218992884254,-4.3744659496245,-3118504640745296,-1.666020102081847,-1.51407789377241373,-1.51306470109503133.2732387410942465,2.2453286293698977,0.9749483649128511,0.472715919767034,0.11249067642678866,-0.1927487640318992,-0.242623087509772,0.3645480814147444,0.5060378572115204,-0.793996411313405,-0.5934442588699886,-0.68076105511004,-0.2967506177492105
-
通过javscript文件
var express = require('express'); var app = express(); const fs = require('fs'); var Meyda = require('meyda'); var load = require('audio-loader') let filename = "1600153162.63571.wav" load(filename).then(function (buffer) { const channelData = buffer.getChannelData(0) const PaddingLength = (Math.pow(2,Math.round(Math.log2(channelData.length)+1)) - channelData.length) let halfPaddingLength = parseInt(PaddingLength/2) const pad1 = new Array(halfPaddingLength).fill(0); const pad2 = new Array(PaddingLength - halfPaddingLength).fill(0); let finalBbuffer = [...pad1,...channelData,...pad2] console.log(finalBbuffer.length) let mfccData = Meyda.extract('mfcc', finalBbuffer) console.log("mfccData : ",mfccData); });
结果:
[249.11783051490784,-90.61751411189829,-12.253094024524968,19.88245460444982,-11.661965456271869,-14.795375019626466,7.19298966815922,8.362884489124907,3.9941283332736557,-3.21583888656478287,-2.0395393071161063,-0.488491767514482837,-3.619963273626695]
为什么会有这种差异。如何使它们相同?
它们不同,因为您在代码中填充缓冲区,而命令行工具将文件拆分为具有默认缓冲区大小的多个缓冲区,并为每个段返回MFCC。
为了使它们相同,您可以复制CLI在代码中执行的缓冲区分块,而不是对整个缓冲区进行零填充,或者您可以制作一个对输入进行零填充的CLI。如果您选择后一种方式,我们当然有兴趣将该功能添加到捆绑的CLI中,因此请随时在我们的问题跟踪器上打开一个问题,讨论您是否愿意这样做并做出贡献。
感谢您使用Meyda!