Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -29,51 +29,60 @@ const upload = multer({
|
|
| 29 |
limits: { fileSize: 50 * 1024 * 1024 }
|
| 30 |
});
|
| 31 |
|
| 32 |
-
//
|
| 33 |
const EFFECTS = {
|
| 34 |
lofi: {
|
| 35 |
name: "LoFi Hip Hop",
|
| 36 |
-
|
|
|
|
| 37 |
},
|
| 38 |
|
| 39 |
slowed_reverb: {
|
| 40 |
name: "Slowed + Reverb",
|
| 41 |
-
|
|
|
|
| 42 |
},
|
| 43 |
|
| 44 |
nightcore: {
|
| 45 |
name: "Nightcore",
|
| 46 |
-
|
|
|
|
| 47 |
},
|
| 48 |
|
| 49 |
vaporwave: {
|
| 50 |
name: "Vaporwave",
|
| 51 |
-
|
|
|
|
| 52 |
},
|
| 53 |
|
| 54 |
"8d_audio": {
|
| 55 |
name: "8D Audio",
|
| 56 |
-
|
|
|
|
| 57 |
},
|
| 58 |
|
| 59 |
bass_boosted: {
|
| 60 |
name: "Bass Boosted",
|
| 61 |
-
|
|
|
|
| 62 |
},
|
| 63 |
|
| 64 |
ambient: {
|
| 65 |
name: "Ambient Chill",
|
| 66 |
-
|
|
|
|
| 67 |
},
|
| 68 |
|
| 69 |
tiktok_lofi: {
|
| 70 |
name: "TikTok LoFi",
|
| 71 |
-
|
|
|
|
| 72 |
},
|
| 73 |
|
| 74 |
chill_lofi: {
|
| 75 |
name: "Chill LoFi",
|
| 76 |
-
|
|
|
|
| 77 |
}
|
| 78 |
};
|
| 79 |
|
|
@@ -81,13 +90,14 @@ const EFFECTS = {
|
|
| 81 |
app.get('/', (req, res) => {
|
| 82 |
res.json({
|
| 83 |
status: 'online',
|
| 84 |
-
message: 'π΅ LoFi Remix API v2.
|
| 85 |
-
version: '2.
|
| 86 |
-
performance: '
|
| 87 |
total_effects: Object.keys(EFFECTS).length,
|
| 88 |
available_effects: Object.keys(EFFECTS).map(key => ({
|
| 89 |
id: key,
|
| 90 |
-
name: EFFECTS[key].name
|
|
|
|
| 91 |
})),
|
| 92 |
endpoints: {
|
| 93 |
health: 'GET /',
|
|
@@ -104,7 +114,8 @@ app.get('/effects', (req, res) => {
|
|
| 104 |
total: Object.keys(EFFECTS).length,
|
| 105 |
effects: Object.keys(EFFECTS).map(key => ({
|
| 106 |
id: key,
|
| 107 |
-
name: EFFECTS[key].name
|
|
|
|
| 108 |
}))
|
| 109 |
});
|
| 110 |
});
|
|
@@ -135,17 +146,16 @@ app.post('/process', upload.single('audio'), async (req, res) => {
|
|
| 135 |
const outputPath = path.join(outputsDir, outputFilename);
|
| 136 |
|
| 137 |
console.log(`π΅ Processing: ${EFFECTS[effectType].name}`);
|
|
|
|
| 138 |
|
| 139 |
const effectCommand = EFFECTS[effectType].command;
|
| 140 |
-
|
| 141 |
-
// Optimized FFmpeg command with faster settings
|
| 142 |
const ffmpegCommand = `ffmpeg -i "${inputPath}" -threads 0 ${effectCommand} -y "${outputPath}"`;
|
| 143 |
|
| 144 |
console.log(`βοΈ Starting FFmpeg...`);
|
| 145 |
|
| 146 |
const startTime = Date.now();
|
| 147 |
await execPromise(ffmpegCommand, {
|
| 148 |
-
maxBuffer: 50 * 1024 * 1024
|
| 149 |
});
|
| 150 |
const processingTime = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 151 |
|
|
@@ -163,7 +173,8 @@ app.post('/process', upload.single('audio'), async (req, res) => {
|
|
| 163 |
filename: outputFilename,
|
| 164 |
effect: {
|
| 165 |
id: effectType,
|
| 166 |
-
name: EFFECTS[effectType].name
|
|
|
|
| 167 |
},
|
| 168 |
output: {
|
| 169 |
size_kb: fileSizeKB
|
|
@@ -214,11 +225,11 @@ app.get('/download/:filename', (req, res) => {
|
|
| 214 |
|
| 215 |
// π Start Server
|
| 216 |
app.listen(PORT, '0.0.0.0', () => {
|
| 217 |
-
console.log('βββββββββββββββββββββββββββββββββββββββ');
|
| 218 |
-
console.log('π LoFi Remix API v2.
|
| 219 |
-
console.log('βββββββββββββββββββββββββββββββββββββββ');
|
| 220 |
console.log(`π Server: http://0.0.0.0:${PORT}`);
|
| 221 |
-
console.log(`β‘ Performance: Fast
|
| 222 |
-
console.log(`π΅ Effects: ${Object.keys(EFFECTS).length}`);
|
| 223 |
-
console.log('βββββββββββββββββββββββββββββββββββββββ');
|
| 224 |
});
|
|
|
|
| 29 |
limits: { fileSize: 50 * 1024 * 1024 }
|
| 30 |
});
|
| 31 |
|
| 32 |
+
// π΅ DISTINCT CHARACTER EFFECTS - Each with unique feel
|
| 33 |
const EFFECTS = {
|
| 34 |
lofi: {
|
| 35 |
name: "LoFi Hip Hop",
|
| 36 |
+
description: "Vintage warmth, breathing bass, vinyl crackle feel",
|
| 37 |
+
command: `-af "asetrate=44100*0.88,aresample=44100,bass=g=8:f=85:width_type=h:width=100,treble=g=-6:f=8000,equalizer=f=200:t=q:width=1.5:g=-3,equalizer=f=800:t=q:width=2:g=2,equalizer=f=3000:t=q:width=3:g=-4,acompressor=threshold=-20dB:ratio=4:attack=5:release=100:makeup=4,vibrato=f=0.3:d=0.6,chorus=0.5:0.9:50:0.4:0.25:2,highpass=f=60,lowpass=f=3800,volume=1.3" -ar 44100 -b:a 192k`
|
| 38 |
},
|
| 39 |
|
| 40 |
slowed_reverb: {
|
| 41 |
name: "Slowed + Reverb",
|
| 42 |
+
description: "Deep slow tempo, cathedral reverb, dreamy space",
|
| 43 |
+
command: `-af "atempo=0.75,asetrate=44100*0.90,aresample=44100,bass=g=6:f=80:width_type=h:width=120,reverb=roomsize=0.95:time=8:wetlevel=0.5:drylevel=0.5,aecho=0.8:0.88:120:0.4,aecho=0.7:0.78:200:0.3,equalizer=f=100:t=q:width=2:g=5,equalizer=f=4000:t=q:width=4:g=-5,chorus=0.6:0.9:55:0.4:0.25:2,acompressor=threshold=-16dB:ratio=2.5:attack=15:release=200:makeup=2,highpass=f=50,lowpass=f=6500,volume=1.4" -ar 44100 -b:a 192k`
|
| 44 |
},
|
| 45 |
|
| 46 |
nightcore: {
|
| 47 |
name: "Nightcore",
|
| 48 |
+
description: "High energy, bright sparkle, anime vocals",
|
| 49 |
+
command: `-af "atempo=1.35,asetrate=44100*1.20,aresample=44100,treble=g=8:f=5000:width_type=h:width=3000,bass=g=-4:f=100,equalizer=f=2000:t=q:width=2:g=3,equalizer=f=6000:t=q:width=3:g=5,equalizer=f=10000:t=q:width=4:g=6,acompressor=threshold=-14dB:ratio=4:attack=2:release=25:makeup=5,crystalizer=i=2:c=1,highpass=f=150,volume=1.4" -ar 44100 -b:a 192k`
|
| 50 |
},
|
| 51 |
|
| 52 |
vaporwave: {
|
| 53 |
name: "Vaporwave",
|
| 54 |
+
description: "Retro aesthetic, dreamy pitch, nostalgic vibe",
|
| 55 |
+
command: `-af "asetrate=44100*0.82,aresample=44100,equalizer=f=300:t=q:width=2:g=5,equalizer=f=1500:t=q:width=3:g=-2,equalizer=f=6000:t=q:width=4:g=-5,aphaser=in_gain=0.6:out_gain=0.8:delay=5:decay=0.6:speed=0.25,chorus=0.7:0.9:60:0.45:0.3:3,vibrato=f=0.15:d=0.6,reverb=roomsize=0.75:time=6:wetlevel=0.4:drylevel=0.6,acompressor=threshold=-18dB:ratio=3:attack=12:release=150:makeup=2,highpass=f=70,lowpass=f=5000,volume=1.2" -ar 44100 -b:a 192k`
|
| 56 |
},
|
| 57 |
|
| 58 |
"8d_audio": {
|
| 59 |
name: "8D Audio",
|
| 60 |
+
description: "360Β° rotation, immersive headphone experience",
|
| 61 |
+
command: `-af "apulsator=hz=0.08:mode=sine:width=0.95,extrastereo=m=3.5:c=1,aecho=0.8:0.9:80:0.4,aecho=0.7:0.8:140:0.3,haas=level_in=1:level_out=1.2:side_gain=1:middle_source=mid,bass=g=4:f=85,reverb=roomsize=0.7:time=5:wetlevel=0.35:drylevel=0.65,acompressor=threshold=-16dB:ratio=2.5:attack=8:release=80:makeup=2,highpass=f=60,volume=1.15" -ar 44100 -b:a 192k`
|
| 62 |
},
|
| 63 |
|
| 64 |
bass_boosted: {
|
| 65 |
name: "Bass Boosted",
|
| 66 |
+
description: "Maximum sub-bass, car audio punch",
|
| 67 |
+
command: `-af "bass=g=20:f=60:width_type=o:width=1.5,bass=g=15:f=100:width_type=h:width=80,equalizer=f=40:t=q:width=1.2:g=12,equalizer=f=80:t=q:width=1.5:g=10,equalizer=f=150:t=q:width=2:g=8,equalizer=f=500:t=q:width=2:g=-3,equalizer=f=4000:t=q:width=4:g=-6,acompressor=threshold=-22dB:ratio=8:attack=3:release=40:makeup=8,highpass=f=30,volume=1.2" -ar 44100 -b:a 192k`
|
| 68 |
},
|
| 69 |
|
| 70 |
ambient: {
|
| 71 |
name: "Ambient Chill",
|
| 72 |
+
description: "Ethereal space, long reverb tails, meditation",
|
| 73 |
+
command: `-af "asetrate=44100*0.94,aresample=44100,reverb=roomsize=0.98:time=10:wetlevel=0.6:drylevel=0.4,aecho=0.6:0.75:180:0.35,aecho=0.5:0.65:320:0.25,aecho=0.4:0.55:500:0.15,chorus=0.65:0.9:48:0.45:0.28:4,aphaser=in_gain=0.4:out_gain=0.7:delay=4:decay=0.5:speed=0.3,equalizer=f=1500:t=q:width=3:g=-3,equalizer=f=6000:t=q:width=4:g=-6,acompressor=threshold=-18dB:ratio=2:attack=20:release=250:makeup=1.5,highpass=f=50,lowpass=f=8000,volume=1.0" -ar 44100 -b:a 192k`
|
| 74 |
},
|
| 75 |
|
| 76 |
tiktok_lofi: {
|
| 77 |
name: "TikTok LoFi",
|
| 78 |
+
description: "Viral TikTok style, punchy bass, modern lofi",
|
| 79 |
+
command: `-af "asetrate=44100*0.86,aresample=44100,bass=g=9:f=90:width_type=h:width=100,treble=g=-7:f=7500,equalizer=f=180:t=q:width=1.8:g=-2.5,equalizer=f=750:t=q:width=2.5:g=3,equalizer=f=2800:t=q:width=3:g=-3,acompressor=threshold=-18dB:ratio=5:attack=4:release=90:makeup=5,vibrato=f=0.28:d=0.65,aphaser=in_gain=0.65:out_gain=0.85:delay=2.2:decay=0.55:speed=0.5,chorus=0.55:0.85:45:0.35:0.22:2,highpass=f=65,lowpass=f=4200,volume=1.35" -ar 44100 -b:a 192k`
|
| 80 |
},
|
| 81 |
|
| 82 |
chill_lofi: {
|
| 83 |
name: "Chill LoFi",
|
| 84 |
+
description: "Study beats, relaxing, smooth jazzy feel",
|
| 85 |
+
command: `-af "asetrate=44100*0.92,aresample=44100,bass=g=6:f=88:width_type=h:width=90,treble=g=-5:f=7000,equalizer=f=250:t=q:width=2:g=-2,equalizer=f=1000:t=q:width=2.5:g=1.5,equalizer=f=3500:t=q:width=3:g=-3,acompressor=threshold=-19dB:ratio=3.5:attack=8:release=130:makeup=3,vibrato=f=0.18:d=0.5,chorus=0.45:0.85:48:0.3:0.2:2,reverb=roomsize=0.6:time=4:wetlevel=0.3:drylevel=0.7,highpass=f=70,lowpass=f=4500,volume=1.2" -ar 44100 -b:a 192k`
|
| 86 |
}
|
| 87 |
};
|
| 88 |
|
|
|
|
| 90 |
app.get('/', (req, res) => {
|
| 91 |
res.json({
|
| 92 |
status: 'online',
|
| 93 |
+
message: 'π΅ LoFi Remix API v2.1 - Distinct Character',
|
| 94 |
+
version: '2.1',
|
| 95 |
+
performance: 'Optimized with unique character per effect',
|
| 96 |
total_effects: Object.keys(EFFECTS).length,
|
| 97 |
available_effects: Object.keys(EFFECTS).map(key => ({
|
| 98 |
id: key,
|
| 99 |
+
name: EFFECTS[key].name,
|
| 100 |
+
description: EFFECTS[key].description
|
| 101 |
})),
|
| 102 |
endpoints: {
|
| 103 |
health: 'GET /',
|
|
|
|
| 114 |
total: Object.keys(EFFECTS).length,
|
| 115 |
effects: Object.keys(EFFECTS).map(key => ({
|
| 116 |
id: key,
|
| 117 |
+
name: EFFECTS[key].name,
|
| 118 |
+
description: EFFECTS[key].description
|
| 119 |
}))
|
| 120 |
});
|
| 121 |
});
|
|
|
|
| 146 |
const outputPath = path.join(outputsDir, outputFilename);
|
| 147 |
|
| 148 |
console.log(`π΅ Processing: ${EFFECTS[effectType].name}`);
|
| 149 |
+
console.log(`π ${EFFECTS[effectType].description}`);
|
| 150 |
|
| 151 |
const effectCommand = EFFECTS[effectType].command;
|
|
|
|
|
|
|
| 152 |
const ffmpegCommand = `ffmpeg -i "${inputPath}" -threads 0 ${effectCommand} -y "${outputPath}"`;
|
| 153 |
|
| 154 |
console.log(`βοΈ Starting FFmpeg...`);
|
| 155 |
|
| 156 |
const startTime = Date.now();
|
| 157 |
await execPromise(ffmpegCommand, {
|
| 158 |
+
maxBuffer: 50 * 1024 * 1024
|
| 159 |
});
|
| 160 |
const processingTime = ((Date.now() - startTime) / 1000).toFixed(2);
|
| 161 |
|
|
|
|
| 173 |
filename: outputFilename,
|
| 174 |
effect: {
|
| 175 |
id: effectType,
|
| 176 |
+
name: EFFECTS[effectType].name,
|
| 177 |
+
description: EFFECTS[effectType].description
|
| 178 |
},
|
| 179 |
output: {
|
| 180 |
size_kb: fileSizeKB
|
|
|
|
| 225 |
|
| 226 |
// π Start Server
|
| 227 |
app.listen(PORT, '0.0.0.0', () => {
|
| 228 |
+
console.log('βββββββββββββββββββββββββββββββββββββββββββββββ');
|
| 229 |
+
console.log('π LoFi Remix API v2.1 - DISTINCT CHARACTER');
|
| 230 |
+
console.log('βββββββββββββββββββββββββββββββββββββββββββββββ');
|
| 231 |
console.log(`π Server: http://0.0.0.0:${PORT}`);
|
| 232 |
+
console.log(`β‘ Performance: Fast + Unique per effect`);
|
| 233 |
+
console.log(`π΅ Effects: ${Object.keys(EFFECTS).length} distinct styles`);
|
| 234 |
+
console.log('βββββββββββββββββββββββββββββββββββββββββββββββ');
|
| 235 |
});
|