Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const express = require('express');
const bodyParser = require('body-parser');
const mm = require('@magenta/music/node/music_vae');
const mmcore = require('@magenta/music/node/core');
//const tf = require('@tensorflow/tfjs-node');
// Fix: magenta.js uses performance.now() for timing logging
// And fetch for the checkpoint, so fake both :/
if (!global.performance) global.performance = require('perf_hooks').performance;
global.fetch = require('node-fetch');
// If you run this locally, and not on Glitch, you might not have the
// env variables set.
const PORT = process.env && process.env.PORT ? process.env.PORT : 9876;
const mvae = new mm.MusicVAE('https://storage.googleapis.com/magentadata/js/checkpoints/groovae/tap2drum_2bar');
warmUpModel();
// http://expressjs.com/en/starter/static-files.html
const app = express();
app.use(express.static('client'));
app.use(bodyParser.json());
app.get('/', function(request, response) {
response.sendFile(__dirname + '/client/index.html');
});
app.post('/drumify', async function(request, response) {
if (!mvae.isInitialized()) {
await mvae.initialize();
}
const original_ns = request.body;