Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,68 +1,79 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
| 2 |
from pydub import AudioSegment
|
|
|
|
| 3 |
|
| 4 |
def brain_v11(t, r, p):
|
| 5 |
-
if t is None:
|
|
|
|
| 6 |
try:
|
| 7 |
y, sr = librosa.load(t, duration=30)
|
| 8 |
c = librosa.feature.chroma_cqt(y=y, sr=sr)
|
| 9 |
nt = ["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]
|
| 10 |
k = nt[np.argmax(np.mean(c, axis=1))]
|
| 11 |
|
|
|
|
| 12 |
S = np.abs(librosa.stft(y))
|
| 13 |
-
|
| 14 |
-
lo = np.mean(S[
|
| 15 |
-
mi = np.mean(S[(
|
| 16 |
-
hi = np.mean(S[
|
| 17 |
|
| 18 |
-
# DIAGNOSTICO
|
| 19 |
-
d =
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
else:
|
| 23 |
-
d += "✅
|
| 24 |
|
| 25 |
-
if hi < mi*0.4:
|
| 26 |
-
d += "
|
| 27 |
else:
|
| 28 |
-
d += "✅ BRILLO:
|
| 29 |
|
| 30 |
-
d += "---
|
| 31 |
-
d += "1.
|
| 32 |
-
d += "2.
|
| 33 |
-
d += "3.
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
cp = "--- ANALISIS
|
| 37 |
if r is not None:
|
| 38 |
yr, _ = librosa.load(r, duration=30)
|
| 39 |
rms_t = np.sqrt(np.mean(y**2))
|
| 40 |
rms_r = np.sqrt(np.mean(yr**2))
|
| 41 |
df = 20 * np.log10(rms_r / (rms_t + 1e-6))
|
| 42 |
|
| 43 |
-
cp +=
|
| 44 |
if df > 3:
|
| 45 |
-
cp += "👉
|
| 46 |
|
| 47 |
# Comparar energia de agudos
|
| 48 |
-
|
|
|
|
| 49 |
if hi < hi_r * 0.7:
|
| 50 |
-
cp += "
|
| 51 |
else:
|
| 52 |
-
cp += "
|
| 53 |
else:
|
| 54 |
-
cp += "Sube un
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
v = "https://images.unsplash.com/photo-1598488035139-bdbb2231ce04?q=80&w=500"
|
| 59 |
return "master.wav", d, cp, k, v
|
| 60 |
except Exception as e:
|
| 61 |
-
return None,
|
| 62 |
|
| 63 |
css = "body, .gradio-container {background-color:#000!important; color:#f80!important;} .gr-button-primary {background:#f80!important; border:none!important; color:#000!important;}"
|
|
|
|
| 64 |
with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
|
| 65 |
-
gr.Markdown("# 💀 DNB GHOST BRAIN v11.
|
| 66 |
with gr.Row():
|
| 67 |
with gr.Column():
|
| 68 |
i_t = gr.Audio(label="TU TRACK", type="filepath")
|
|
@@ -72,9 +83,10 @@ with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
|
|
| 72 |
o_k = gr.Label(label="KEY")
|
| 73 |
with gr.Column():
|
| 74 |
o_i = gr.Textbox(label="DIAGNOSTICO Y VSTs", lines=15)
|
| 75 |
-
o_a = gr.Audio(label="MASTER")
|
| 76 |
with gr.Column():
|
| 77 |
-
o_c = gr.Textbox(label="
|
| 78 |
o_v = gr.Image(label="VIBE")
|
| 79 |
bn.click(brain_v11, [i_t, i_r, i_s], [o_a, o_i, o_c, o_k, o_v])
|
|
|
|
| 80 |
demo.launch()
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import librosa
|
| 3 |
+
import numpy as np
|
| 4 |
from pydub import AudioSegment
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
def brain_v11(t, r, p):
|
| 8 |
+
if t is None:
|
| 9 |
+
return None, "Sube audio.", "Sin ref.", "...", "https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17?q=80&w=500"
|
| 10 |
try:
|
| 11 |
y, sr = librosa.load(t, duration=30)
|
| 12 |
c = librosa.feature.chroma_cqt(y=y, sr=sr)
|
| 13 |
nt = ["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"]
|
| 14 |
k = nt[np.argmax(np.mean(c, axis=1))]
|
| 15 |
|
| 16 |
+
# Analisis de frecuencias
|
| 17 |
S = np.abs(librosa.stft(y))
|
| 18 |
+
freqs = librosa.fft_frequencies(sr=sr)
|
| 19 |
+
lo = np.mean(S[freqs < 150])
|
| 20 |
+
mi = np.mean(S[(freqs >= 150) & (freqs < 2000)])
|
| 21 |
+
hi = np.mean(S[freqs >= 2000])
|
| 22 |
|
| 23 |
+
# DIAGNOSTICO DETALLADO
|
| 24 |
+
d = "--- ANALISIS PROFESIONAL ---\n"
|
| 25 |
+
d += "NOTA DOMINANTE: " + k + "\n\n"
|
| 26 |
+
|
| 27 |
+
if lo > mi * 1.3:
|
| 28 |
+
d += "⚠️ GRAVES: Tienes exceso de sub-bass. Baja el fader de tu sintetizador de bajo -4dB para que el Kick respire.\n"
|
| 29 |
else:
|
| 30 |
+
d += "✅ GRAVES: El balance de bajos es correcto.\n"
|
| 31 |
|
| 32 |
+
if hi < mi * 0.4:
|
| 33 |
+
d += "⚠️ BRILLO: Tu mezcla suena oscura. Añade un EQ 'High Shelf' en 10kHz (+3dB) a tus Hi-Hats.\n\n"
|
| 34 |
else:
|
| 35 |
+
d += "✅ BRILLO: La mezcla tiene aire.\n\n"
|
| 36 |
|
| 37 |
+
d += "--- GUIA DE VSTs ---\n"
|
| 38 |
+
d += "1. FABFILTER PRO-C2: Ponlo en el bus de drums. Attack: 15ms para no matar el golpe del kick. Ratio: 4:1.\n"
|
| 39 |
+
d += "2. DECAPITATOR: Usalo en el Bass. Modo 'E' (EMI) con Drive en 2.5 para que el bajo se escuche en el movil.\n"
|
| 40 |
+
d += "3. VINTAGEVERB: Solo en leads. Corta el 'Low Cut' a 400Hz dentro del plugin para evitar barro."
|
| 41 |
|
| 42 |
+
# REFERENCIA ENTENDIBLE
|
| 43 |
+
cp = "--- ANALISIS DE TU TEMA VS REFERENCIA ---\n\n"
|
| 44 |
if r is not None:
|
| 45 |
yr, _ = librosa.load(r, duration=30)
|
| 46 |
rms_t = np.sqrt(np.mean(y**2))
|
| 47 |
rms_r = np.sqrt(np.mean(yr**2))
|
| 48 |
df = 20 * np.log10(rms_r / (rms_t + 1e-6))
|
| 49 |
|
| 50 |
+
cp += "• POTENCIA: Tu tema esta " + str(round(df, 1)) + "dB por debajo del nivel comercial.\n"
|
| 51 |
if df > 3:
|
| 52 |
+
cp += "👉 CONSEJO: Tu track suena flojo. Empuja el limitador final hasta que empieces a perder pegada.\n\n"
|
| 53 |
|
| 54 |
# Comparar energia de agudos
|
| 55 |
+
S_r = np.abs(librosa.stft(yr))
|
| 56 |
+
hi_r = np.mean(S_r[freqs >= 2000])
|
| 57 |
if hi < hi_r * 0.7:
|
| 58 |
+
cp += "• DENSIDAD: Te falta percusion aguda. Añade shakers o rides para llenar el espectro como el tema Pro.\n"
|
| 59 |
else:
|
| 60 |
+
cp += "• DENSIDAD: El espectro esta bien lleno."
|
| 61 |
else:
|
| 62 |
+
cp += "Sube un track de Noisia o Metrik para comparar."
|
| 63 |
|
| 64 |
+
# Mastering
|
| 65 |
+
audio = AudioSegment.from_file(t).apply_gain((p / 10) - 5)
|
| 66 |
+
audio.export("master.wav", format="wav")
|
| 67 |
+
|
| 68 |
v = "https://images.unsplash.com/photo-1598488035139-bdbb2231ce04?q=80&w=500"
|
| 69 |
return "master.wav", d, cp, k, v
|
| 70 |
except Exception as e:
|
| 71 |
+
return None, "Error: " + str(e), "!", "!", None
|
| 72 |
|
| 73 |
css = "body, .gradio-container {background-color:#000!important; color:#f80!important;} .gr-button-primary {background:#f80!important; border:none!important; color:#000!important;}"
|
| 74 |
+
|
| 75 |
with gr.Blocks(theme=gr.themes.Monochrome(), css=css) as demo:
|
| 76 |
+
gr.Markdown("# 💀 DNB GHOST BRAIN v11.5")
|
| 77 |
with gr.Row():
|
| 78 |
with gr.Column():
|
| 79 |
i_t = gr.Audio(label="TU TRACK", type="filepath")
|
|
|
|
| 83 |
o_k = gr.Label(label="KEY")
|
| 84 |
with gr.Column():
|
| 85 |
o_i = gr.Textbox(label="DIAGNOSTICO Y VSTs", lines=15)
|
| 86 |
+
o_a = gr.Audio(label="TU MASTER")
|
| 87 |
with gr.Column():
|
| 88 |
+
o_c = gr.Textbox(label="ESTUDIO DE REFERENCIA", lines=12)
|
| 89 |
o_v = gr.Image(label="VIBE")
|
| 90 |
bn.click(brain_v11, [i_t, i_r, i_s], [o_a, o_i, o_c, o_k, o_v])
|
| 91 |
+
|
| 92 |
demo.launch()
|