soiz1 commited on
Commit
c639c08
·
verified ·
1 Parent(s): b923ace

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +25 -22
index.html CHANGED
@@ -375,28 +375,31 @@ function extractFeatures(essentia, audioData) {
375
  }
376
  };
377
 
378
- for (let i = 0; i < frames.size(); i++) {
379
- const frame = frames.get(i);
380
-
381
- // MFCC (メル周波数ケプストラム係数)
382
- const mfcc = essentia.MFCC(
383
- essentia.Spectrum(essentia.Windowing(frame, 'hann', frameSize, false)).bands;
384
- features.mfcc.push(mfcc);
385
-
386
- // スペクトル特徴量
387
- const spectrum = essentia.Spectrum(essentia.Windowing(frame, 'hann', frameSize, false));
388
- features.spectral.centroid.push(
389
- essentia.SpectralCentroid(spectrum).centroid
390
- );
391
- features.spectral.rolloff.push(
392
- essentia.SpectralRollOff(spectrum, 0.85).rollOff
393
- );
394
- features.spectral.flux.push(
395
- essentia.Flux(spectrum).flux
396
- );
397
-
398
- frame.delete();
399
- }
 
 
 
400
 
401
  frames.delete();
402
  return features;
 
375
  }
376
  };
377
 
378
+ for (let i = 0; i < frames.size(); i++) {
379
+ const frame = frames.get(i);
380
+
381
+ // ウィンドウ処理 → スペクトル変換(共通処理)
382
+ const windowed = essentia.Windowing(frame, 'hann', frameSize, false);
383
+ const spectrum = essentia.Spectrum(windowed);
384
+
385
+ // MFCC
386
+ const mfccResult = essentia.MFCC(spectrum);
387
+ features.mfcc.push(mfccResult.mfcc); // .mfcc 部分だけ取り出して保存
388
+
389
+ // スペクトル特徴量
390
+ features.spectral.centroid.push(
391
+ essentia.SpectralCentroid(spectrum).centroid
392
+ );
393
+ features.spectral.rolloff.push(
394
+ essentia.SpectralRollOff(spectrum, 0.85).rollOff
395
+ );
396
+ features.spectral.flux.push(
397
+ essentia.Flux(spectrum).flux
398
+ );
399
+
400
+ frame.delete(); // メモリ解放(必要であれば)
401
+ }
402
+
403
 
404
  frames.delete();
405
  return features;