How to use the @magenta/music/node/music_vae.MusicVAE function in @magenta/music

To help you get started, we’ve selected a few @magenta/music examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github magenta / drumbot / server / app.js View on Github external
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;

@magenta/music

Make music with machine learning, in the browser.

Apache-2.0
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages