Spaces:
Running
Running
File size: 9,480 Bytes
b162b24 3bc81b1 b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 3bc81b1 b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 173eaab b162b24 1e8447a 4f93fde 1e8447a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
export const LENGTHS = [
{ value: 5, label: "00:05" },
{ value: 10, label: "00:10" },
{ value: 15, label: "00:15" },
{ value: 30, label: "00:30" },
];
export const STYLES = [{
value: "none",
prompt: "",
label: "None",
},{
value: "hiphop",
prompt: "Hip Hop and Rap track",
label: "Hip Hop",
image: "https://images.unsplash.com/photo-1601643157091-ce5c665179ab?q=80&w=2072&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
}, {
value: "classic",
prompt: "Classic track",
label: "Classic",
image: "https://images.unsplash.com/photo-1519139270028-ab664cf42264?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "jazz",
prompt: "Jazz track",
label: "Jazz",
image: "https://images.unsplash.com/photo-1511192336575-5a79af67a629?q=80&w=2064&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "electro",
prompt: "Electronic and dance track",
label: "Electro & Dance",
image: "https://images.unsplash.com/photo-1622386010273-646e12d1c02f?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "rock",
prompt: "Rock'n'Roll track",
label: "Rock'N'Roll",
image: "https://plus.unsplash.com/premium_photo-1681876467464-33495108737c?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "funk",
prompt: "Funk track",
label: "Funk",
image: "https://plus.unsplash.com/premium_photo-1683129651802-1c7ba429a137?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "dubstep",
prompt: "Dubstep track",
label: "Dubstep",
image: "https://images.unsplash.com/photo-1578946956088-940c3b502864?q=80&w=2046&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "afrobeats",
prompt: "Afrobeats track",
label: "Afrobeats",
image: "https://plus.unsplash.com/premium_photo-1702220976033-50f47c7a58a6?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "orchestral",
prompt: "Orchestral track",
label: "Orchestral",
image: "https://plus.unsplash.com/premium_photo-1682098438728-fa774b584c18?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "pop",
prompt: "Pop track",
label: "Pop",
image: "https://images.unsplash.com/photo-1520872024865-3ff2805d8bb3?q=80&w=2104&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "reggae",
prompt: "Reggae track",
label: "Reggae",
image: "https://images.unsplash.com/photo-1538598450935-581f6a5fa7e0?q=80&w=2088&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "metal",
prompt: "Metal track",
label: "Metal",
image: "https://images.unsplash.com/photo-1506091403742-e3aa39518db5?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "country",
prompt: "Country track",
label: "Country",
image: "https://images.unsplash.com/photo-1525814230241-7f78c608c54c?q=80&w=1976&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "blues",
prompt: "Blues track",
label: "Blues",
image: "https://plus.unsplash.com/premium_photo-1661333454734-9184250f7226?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "soul",
prompt: "Soul track",
label: "Soul",
image: "https://images.unsplash.com/photo-1581297848080-c84ac0438210?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "rnb",
prompt: "R'n'B track",
label: "R&B",
image: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR3D-yMSiaEBtOOoxrKh8InCYzRqjn1UnYVHPhbDGkPrXH32k7i091MRvRTP7Nyts8dMJY&usqp=CAU"
}, {
value: "disco",
prompt: "Disco track",
label: "Disco",
image: "https://images.unsplash.com/photo-1559424452-eeb3a13ffe2b?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "trap",
prompt: "Trap track",
label: "Trap",
image: "https://images.unsplash.com/photo-1620281428428-bce2bf9ceee4?q=80&w=1970&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "ambient",
prompt: "Ambient track",
label: "Ambient",
image: "https://images.unsplash.com/photo-1616085290694-4b9cc5c97a12?q=80&w=2128&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}, {
value: "lofi",
prompt: "Lofi track",
label: "Lofi",
image: "https://miro.medium.com/v2/resize:fit:1358/0*FjF2hZ8cJQN9aBxk.jpg"
}, {
value: "chill",
prompt: "Chill track",
label: "Chill",
image: "https://images.unsplash.com/photo-1531574373289-ad0d66e39ba9?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
}]
export const MOODS = [{
value: "none",
label: "None",
prompt: "",
emoji: ""
},{
value: "happy",
label: "Happy",
prompt: "with an happy vibe",
emoji: "😊"
}, {
value: "sad",
label: "Sad",
prompt: "with a sad vibe",
emoji: "😢"
}, {
value: "angry",
label: "Angry",
prompt: "with an angry vibe",
emoji: "😡"
}, {
value: "chill",
label: "Chill",
prompt: "with a chill vibe",
emoji: "😌"
}, {
value: "romantic",
label: "Romantic",
prompt: "with a romantic vibe",
emoji: "😍"
}, {
value: "epic",
label: "Epic",
prompt: "with an epic vibe",
emoji: "🚀"
}, {
value: "energetic",
label: "Energetic",
prompt: "with an energetic vibe",
emoji: "🔥"
}, {
value: "dreamy",
label: "Dreamy",
prompt: "with a dreamy vibe",
emoji: "🌌"
}, {
value: "mysterious",
label: "Mysterious",
prompt: "with a mysterious vibe",
emoji: "🕵️"
}, {
value: "relaxing",
label: "Relaxing",
prompt: "with a relaxing vibe",
emoji: "😴"
}, {
value: "dark",
label: "Dark",
prompt: "with a dark vibe",
emoji: "🖤"
}, {
value: "upbeat",
label: "Upbeat",
prompt: "with an upbeat vibe",
emoji: "🎉"
}, {
value: "motivational",
label: "Motivational",
prompt: "with a motivational vibe",
emoji: "💪"
}, {
value: "inspiring",
label: "Inspiring",
prompt: "with an inspiring vibe",
emoji: "🌟"
}, {
value: "nostalgic",
label: "Nostalgic",
prompt: "with a nostalgic vibe",
emoji: "📼"
}, {
value: "groovy",
label: "Groovy",
prompt: "with a groovy vibe",
emoji: "🕺"
}, {
value: "melancholic",
label: "Melancholic",
prompt: "with a melancholic vibe",
emoji: "😔"
}, {
value: "hopeful",
label: "Hopeful",
prompt: "with a hopeful vibe",
emoji: "🌈"
}]
export const MUSIC_PROMPTS = [
'80s pop track with bassy drums and synth',
'90s rock song with loud guitars and heavy drums',
'a light and cheerly EDM track, with syncopated drums, aery pads, and strong emotions bpm: 130',
'A cheerful country song with acoustic guitars',
'lofi slow bpm electro chill with organic samples',
]
export function encodeWAV(samples: any[], sampleRate = 16000) {
let offset = 44;
const buffer = new ArrayBuffer(offset + samples.length * 4);
const view = new DataView(buffer);
/* RIFF identifier */
writeString(view, 0, 'RIFF')
/* RIFF chunk length */
view.setUint32(4, 36 + samples.length * 4, true)
/* RIFF type */
writeString(view, 8, 'WAVE')
/* format chunk identifier */
writeString(view, 12, 'fmt ')
/* format chunk length */
view.setUint32(16, 16, true)
/* sample format (raw) */
view.setUint16(20, 3, true)
/* channel count */
view.setUint16(22, 1, true)
/* sample rate */
view.setUint32(24, sampleRate, true)
/* byte rate (sample rate * block align) */
view.setUint32(28, sampleRate * 4, true)
/* block align (channel count * bytes per sample) */
view.setUint16(32, 4, true)
/* bits per sample */
view.setUint16(34, 32, true)
/* data chunk identifier */
writeString(view, 36, 'data')
/* data chunk length */
view.setUint32(40, samples.length * 4, true)
for (let i = 0; i < samples.length; ++i, offset += 4) {
view.setFloat32(offset, samples[i], true)
}
return buffer
}
function writeString(view: any, offset: number, string: string) {
for (let i = 0; i < string.length; ++i) {
view.setUint8(offset + i, string.charCodeAt(i))
}
}
export const MODEL_ID = 'Xenova/musicgen-small';
export async function share(body: any, settings: Record<string, any>, results: Record<string, any>) {
const response = await fetch('https://huggingface.co/uploads', { method: 'POST', body });
if (!response.ok) throw new Error(`Failed to upload audio: ${response.statusText}`);
const url = await response.text();
const params = new URLSearchParams({
title: `🎵 ${results.title}`,
description: `<audio controls src="${url}"></audio>\n${JSON.stringify(settings, null, 2)}`,
});
const shareURL = `https://huggingface.co/spaces/enzostvs/ai-jukebox/discussions/new?${params.toString()}`;
window.open(shareURL, '_blank');
} |