Spaces:
Runtime error

yue2-studio / src /lib /presets.ts
RalphThings's picture
Upload folder using huggingface_hub
bf68acd verified
Raw History Blame Contribute Delete
3.25 kB
import type { AdvancedParams } from "@/lib/types";
/**
* YuE2 reads style as free prose. These chips are shortcuts that append to the
* field, grouped the way the model card describes a style string: what kind of
* music, who is singing, what is playing, how it was recorded.
*/
export const STYLE_GROUPS: { label: string; tags: string[] }[] = [
{
label: "Kind",
tags: [
"indie pop",
"soul ballad",
"jazz funk",
"drum and bass",
"alt country",
"shoegaze",
"city pop",
"gospel",
"trip hop",
"afrobeats",
],
},
{
label: "Voice",
tags: [
"warm female lead",
"gravel male lead",
"close double tracked vocal",
"choir stack on the chorus",
"spoken verse, sung chorus",
"no vocal",
],
},
{
label: "Players",
tags: [
"Rhodes piano",
"upright bass",
"brushed drums",
"nylon string guitar",
"analog synth pads",
"horn section",
"string quartet",
"808 sub",
],
},
{
label: "Room",
tags: [
"live band, one room",
"tape saturation",
"dry and close",
"wide reverb tail",
"lo-fi cassette",
"modern polished mix",
],
},
{
label: "Tempo",
tags: ["68 BPM", "92 BPM", "110 BPM", "128 BPM", "halftime feel", "swung eighths"],
},
];
export const SECTION_TAGS = ["[Verse]", "[Chorus]", "[Bridge]", "[Intro]", "[Outro]"];
export const STARTER_STYLE =
"English soul ballad, warm female lead, Rhodes piano, upright bass, brushed drums, string pads in the last chorus, 68 BPM, live band in one room, tape saturation";
export const STARTER_LYRICS = `[Verse]
The kettle ticks itself to sleep
Your coat still holding yesterday
I count the streetlight on the ceiling
Nine, then eight, then look away
[Chorus]
Say it slow, I have got all night
Every word can take its time
Nothing here is going anywhere
Least of all this heart of mine
[Verse]
Rain has found the kitchen window
Running lines it cannot keep
You are humming something older
Than the both of us asleep
[Chorus]
Say it slow, I have got all night
Every word can take its time
Nothing here is going anywhere
Least of all this heart of mine`;
export const DEFAULT_ADVANCED: AdvancedParams = {
temperature: 1,
topP: 0.95,
topK: 100,
repetitionPenalty: 1.2,
cfgScale: 1,
steps: 32,
samplerName: "dpm_2",
scheduler: "sgm_uniform",
abcTemperature: 0.7,
abcTopP: 0.9,
abcTopK: 30,
abcRepetitionPenalty: 1.005,
maxAbcTokens: 8192,
};
/** Rough read on how long the written lyrics want to run. */
export function estimateSeconds(lyrics: string): number {
const lines = lyrics
.split("\n")
.map((line) => line.trim())
.filter((line) => line.length > 0 && !line.startsWith("["));
const sections = (lyrics.match(/\[[^\]]+\]/g) ?? []).length;
return Math.round(lines.length * 3.4 + sections * 4);
}
export function countSections(lyrics: string): number {
return (lyrics.match(/\[[^\]]+\]/g) ?? []).length;
}
export function formatClock(seconds: number): string {
const safe = Math.max(0, Math.round(seconds));
const minutes = Math.floor(safe / 60);
return `${minutes}:${String(safe % 60).padStart(2, "0")}`;
}