Skip to content

Instantly share code, notes, and snippets.

@WoolDoughnut310
Created October 28, 2022 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WoolDoughnut310/997b30c01e9e53d8cb99d1b283c0e182 to your computer and use it in GitHub Desktop.
Save WoolDoughnut310/997b30c01e9e53d8cb99d1b283c0e182 to your computer and use it in GitHub Desktop.
export const trainWithAudio = async (dir: string) => {
const files = await fs.readdir(dir);
const data: number[][] = [];
let filename: string;
for (let i = 0; i < files.length; i++) {
filename = files[i];
const filepath = path.join(dir, filename);
const audioData = await decodeAudio(filepath);
const features = extractFeatures(audioData);
console.log(i, features);
data.push(features);
}
const vector = new StandardScaler().fitTransform(data);
console.log("data", vector.arraySync());
model.fit(vector);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment