andreasjansson / musicgen-looper

Generate fixed-bpm loops from text prompts

  • Public
  • 56.4K runs
  • A100 (80GB)
  • GitHub
  • Paper
  • License

Input

*string
Shift + Return to add a new line

A description of the music you want to generate.

number
(minimum: 40, maximum: 300)

Tempo in beats per minute

Default: 140

integer
(minimum: 1, maximum: 20)

Number of variations to generate

Default: 4

integer
(minimum: 2, maximum: 20)

Maximum duration of the generated loop in seconds.

Default: 8

string

Model to use for generation. .

Default: "medium"

integer

Reduces sampling to the k most likely tokens.

Default: 250

number

Reduces sampling to tokens with cumulative probability of p. When set to `0` (default), top_k sampling is used.

Default: 0

number

Controls the 'conservativeness' of the sampling process. Higher temperature means more diversity.

Default: 1

integer

Increases the influence of inputs on the output. Higher values produce lower-varience outputs that adhere more closely to inputs.

Default: 3

string

Output format for generated audio.

Default: "wav"

integer

Seed for random number generator. If None or -1, a random seed will be used.

Default: -1

Output

variation_01

Video Player is loading.
Current Time 00:00:000
Duration 00:00:000
Loaded: 0%
Stream Type LIVE
Remaining Time 00:00:000
 
1x

variation_02

Video Player is loading.
Current Time 00:00:000
Duration 00:00:000
Loaded: 0%
Stream Type LIVE
Remaining Time 00:00:000
 
1x

variation_03

Video Player is loading.
Current Time 00:00:000
Duration 00:00:000
Loaded: 0%
Stream Type LIVE
Remaining Time 00:00:000
 
1x

variation_04

Video Player is loading.
Current Time 00:00:000
Duration 00:00:000
Loaded: 0%
Stream Type LIVE
Remaining Time 00:00:000
 
1x
Generated in

Run time and cost

This model costs approximately $0.18 to run on Replicate, or 5 runs per $1, but this varies depending on your inputs. It is also open source and you can run it on your own computer with Docker.

This model runs on Nvidia A100 (80GB) GPU hardware. Predictions typically complete within 127 seconds. The predict time for this model varies significantly based on the inputs.

Readme

MusicGen-Looper

Generate fixed-bpm loops from text prompts

How it works

First a piece of music is generated by running the prompt (appending ", {bpm} bpm") through MusicGen. Then BeatNet detects beats and downbeats. An even number of bars is extracted from the output audio.

Variations are created by using MusicGen’s continuation feature, passing the last bar of the first variation as input to the continuation model.

All variations are time stretched with Rubberband to match the requested tempo exactly. If the actual tempo of the first variation is +/-10 bpm from the requested tempo, an error is thrown.

Failure cases

  • BeatNet often struggles to pick the right downbeat, which causes loops to start on a different beat than 1.
  • MusicGen has its own limitations, e.g. it can’t generate vocals