Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -6,56 +6,12 @@ app = FastAPI()
|
|
| 6 |
TMP = "/tmp/audio"
|
| 7 |
os.makedirs(TMP, exist_ok=True)
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
#
|
| 11 |
-
# 1. asetrate=37485
|
| 12 |
-
# Lowers sample rate to 85% of 44100. This simultaneously slows playback
|
| 13 |
-
# AND lowers pitch β exactly how slowed+reverb tracks are made.
|
| 14 |
-
# (No atempo β that would undo the slowdown.)
|
| 15 |
-
#
|
| 16 |
-
# 2. aresample=44100
|
| 17 |
-
# Resample back to standard 44100 Hz so players read it correctly.
|
| 18 |
-
# The audio remains slow+pitched-down; this just fixes the clock rate.
|
| 19 |
-
#
|
| 20 |
-
# 3. lowpass=f=3500
|
| 21 |
-
# Hard low-pass at 3.5 kHz. Cuts harsh digital highs, cymbals become
|
| 22 |
-
# soft, vocals get that "playing through a wall" warmth. Core lofi sound.
|
| 23 |
-
#
|
| 24 |
-
# 4. equalizer=f=80:width_type=o:width=2:g=3
|
| 25 |
-
# +3 dB boost at 80 Hz (sub-bass warmth). Makes the track feel heavy
|
| 26 |
-
# and warm without booming. width=2 octaves = wide, musical boost.
|
| 27 |
-
#
|
| 28 |
-
# 5. equalizer=f=250:width_type=o:width=1.5:g=-1.5
|
| 29 |
-
# -1.5 dB cut at 250 Hz. Removes boxiness/muddiness that builds up
|
| 30 |
-
# after slowing + bass boost. Keeps the mix clear.
|
| 31 |
-
#
|
| 32 |
-
# 6. equalizer=f=6000:width_type=o:width=2:g=-6
|
| 33 |
-
# -6 dB shelf cut around 6 kHz. Tames presence/brightness further for
|
| 34 |
-
# that cassette-tape dull warmth lofi is known for.
|
| 35 |
-
#
|
| 36 |
-
# 7. aecho=0.7:0.8:18|36|54|72:0.5|0.35|0.2|0.1
|
| 37 |
-
# Multi-tap room reverb simulation:
|
| 38 |
-
# delays = 18|36|54|72 ms β early reflections (NOT echo β way too short)
|
| 39 |
-
# decays = 0.5|0.35|0.2|0.1 β each tap fades steeply = short reverb tail
|
| 40 |
-
# in=0.7, out=0.8 β keep it behind the dry signal
|
| 41 |
-
# This gives a small room / bathroom reverb feel, not a slapback echo.
|
| 42 |
-
#
|
| 43 |
-
# 8. volume=1.5
|
| 44 |
-
# All the cuts + reverb mix reduce level. Bring it back up so output
|
| 45 |
-
# isn't quieter than the input.
|
| 46 |
-
#
|
| 47 |
-
# Output: AAC 256 kbps M4A β transparent quality, 2x faster than MP3 encode
|
| 48 |
-
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 49 |
-
|
| 50 |
FILTER = (
|
| 51 |
-
"asetrate=
|
| 52 |
-
"aresample=44100,"
|
| 53 |
-
"
|
| 54 |
-
"equalizer=f=80:width_type=o:width=2:g=3,"
|
| 55 |
-
"equalizer=f=250:width_type=o:width=1.5:g=-1.5,"
|
| 56 |
-
"equalizer=f=6000:width_type=o:width=2:g=-6,"
|
| 57 |
-
"aecho=0.7:0.8:18|36|54|72:0.5|0.35|0.2|0.1,"
|
| 58 |
-
"volume=1.5"
|
| 59 |
)
|
| 60 |
|
| 61 |
HTML = """<!DOCTYPE html>
|
|
@@ -175,7 +131,7 @@ HTML = """<!DOCTYPE html>
|
|
| 175 |
</head>
|
| 176 |
<body>
|
| 177 |
<h1>β SLOWED + REVERB</h1>
|
| 178 |
-
<p class="subtitle">
|
| 179 |
|
| 180 |
<div class="card">
|
| 181 |
<div class="card-label">// Upload audio file</div>
|
|
@@ -199,10 +155,7 @@ HTML = """<!DOCTYPE html>
|
|
| 199 |
</form>
|
| 200 |
</div>
|
| 201 |
|
| 202 |
-
<p class="info">
|
| 203 |
-
<span>85% speed</span> Β· lowpass 3.5kHz Β· lofi EQ Β· room reverb<br>
|
| 204 |
-
output: <span>AAC 256kbps M4A</span> Β· instant streaming
|
| 205 |
-
</p>
|
| 206 |
</body>
|
| 207 |
</html>"""
|
| 208 |
|
|
|
|
| 6 |
TMP = "/tmp/audio"
|
| 7 |
os.makedirs(TMP, exist_ok=True)
|
| 8 |
|
| 9 |
+
# 0.85 speed + 0.85 pitch via asetrate, then 40% reverb mix via aecho
|
| 10 |
+
# aecho: in=1.0, out=1.0, delay=60ms (short room tail), decay=0.4 (40% wet)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
FILTER = (
|
| 12 |
+
"asetrate=44100*0.85," # slow to 85% + lower pitch to 85%
|
| 13 |
+
"aresample=44100," # restore clock rate for players
|
| 14 |
+
"aecho=1.0:1.0:60:0.4" # 40% reverb β 60ms tail, 0.4 decay = 40% wet
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
)
|
| 16 |
|
| 17 |
HTML = """<!DOCTYPE html>
|
|
|
|
| 131 |
</head>
|
| 132 |
<body>
|
| 133 |
<h1>β SLOWED + REVERB</h1>
|
| 134 |
+
<p class="subtitle">0.85x speed Β· 0.85x pitch Β· 40% reverb</p>
|
| 135 |
|
| 136 |
<div class="card">
|
| 137 |
<div class="card-label">// Upload audio file</div>
|
|
|
|
| 155 |
</form>
|
| 156 |
</div>
|
| 157 |
|
| 158 |
+
<p class="info">output: <span>AAC 256kbps M4A</span></p>
|
|
|
|
|
|
|
|
|
|
| 159 |
</body>
|
| 160 |
</html>"""
|
| 161 |
|