Spaces:
Running
Running
File size: 8,910 Bytes
b162b24 |
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 |
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: "hiphop",
prompt: "hip hop track with a chill vibe",
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 with a chill vibe",
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 with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
label: "R&B",
image: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR3D-yMSiaEBtOOoxrKh8InCYzRqjn1UnYVHPhbDGkPrXH32k7i091MRvRTP7Nyts8dMJY&usqp=CAU"
}, {
value: "disco",
prompt: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
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: "jazz track with a chill vibe",
label: "Lofi",
image: "https://miro.medium.com/v2/resize:fit:1358/0*FjF2hZ8cJQN9aBxk.jpg"
}, {
value: "chill",
prompt: "jazz track with a chill vibe",
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: "happy",
label: "Happy",
prompt: "happy track with a chill vibe",
emoji: "😊"
}, {
value: "sad",
label: "Sad",
prompt: "sad track with a chill vibe",
emoji: "😢"
}, {
value: "angry",
label: "Angry",
prompt: "angry track with a chill vibe",
emoji: "😡"
}, {
value: "chill",
label: "Chill",
prompt: "chill track with a chill vibe",
emoji: "😌"
}, {
value: "romantic",
label: "Romantic",
prompt: "romantic track with a chill vibe",
emoji: "😍"
}, {
value: "epic",
label: "Epic",
prompt: "epic track with a chill vibe",
emoji: "🚀"
}, {
value: "energetic",
label: "Energetic",
prompt: "energetic track with a chill vibe",
emoji: "🔥"
}, {
value: "dreamy",
label: "Dreamy",
prompt: "dreamy track with a chill vibe",
emoji: "🌌"
}, {
value: "mysterious",
label: "Mysterious",
prompt: "mysterious track with a chill vibe",
emoji: "🕵️"
}, {
value: "relaxing",
label: "Relaxing",
prompt: "relaxing track with a chill vibe",
emoji: "😴"
}, {
value: "dark",
label: "Dark",
prompt: "dark track with a chill vibe",
emoji: "🖤"
}, {
value: "upbeat",
label: "Upbeat",
prompt: "upbeat track with a chill vibe",
emoji: "🎉"
}, {
value: "motivational",
label: "Motivational",
prompt: "motivational track with a chill vibe",
emoji: "💪"
}, {
value: "inspiring",
label: "Inspiring",
prompt: "inspiring track with a chill vibe",
emoji: "🌟"
}, {
value: "nostalgic",
label: "Nostalgic",
prompt: "nostalgic track with a chill vibe",
emoji: "📼"
}, {
value: "groovy",
label: "Groovy",
prompt: "groovy track with a chill vibe",
emoji: "🕺"
}, {
value: "melancholic",
label: "Melancholic",
prompt: "melancholic track with a chill vibe",
emoji: "😔"
}, {
value: "hopeful",
label: "Hopeful",
prompt: "hopeful track with a chill vibe",
emoji: "🌈"
}]
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'; |