david174 commited on
Commit
6dd9e14
verified
1 Parent(s): 085ea2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -6,40 +6,40 @@ import os
6
 
7
  def ghost_ultimate_v7(tu_track, track_ref, intensidad, duda):
8
  if tu_track is None:
9
- return None, "鈿狅笍 Sube tu track.", "Esperando...", "https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17?q=80&w=500", "Sube un audio."
10
 
11
  try:
12
- # 1. AN脕LISIS DE AUDIO
13
  y, sr = librosa.load(tu_track, duration=30)
14
-
15
- # Detecci贸n de Nota (Key)
16
  chroma = librosa.feature.chroma_cqt(y=y, sr=sr)
17
  key_idx = np.argmax(np.mean(chroma, axis=1))
18
- notas = ["Do (C)", "Do# (C#)", "Re (D)", "Re# (D#)", "Mi (E)", "Fa (F)",
19
- "Fa# (F#)", "Sol (G)", "Sol# (G#)", "La (A)", "La# (A#)", "Si (B)"]
20
- key_detectada = notas[key_idx]
21
 
22
- # Energ铆a RMS
23
  rms_tu = np.mean(librosa.feature.rms(y=y))
24
- estilo = "Dark/Tech" if rms_tu > 0.12 else "Liquid/Deep"
25
 
26
  # 2. COMPARADOR
27
- comparativa = "No hay referencia."
28
  if track_ref is not None:
29
  y_ref, _ = librosa.load(track_ref, duration=30)
30
  rms_ref = np.mean(librosa.feature.rms(y=y_ref))
31
- dif_db = 20 * np.log10(rms_ref / rms_tu)
32
- comparativa = f"Diferencia: {dif_db:.1f}dB respecto a la referencia."
33
 
34
  # 3. MASTERING
35
  sound = AudioSegment.from_file(tu_track)
36
- ganancia = (intensidad / 10) - 5
37
- mastered = sound.apply_gain(ganancia)
38
- out_path = "master_v7_final.wav"
39
- mastered.export(out_path, format="wav")
40
 
41
- # 4. GENERADOR DE PROMPT
42
- p_arte = f"Cyberpunk DnB Art, Neon Orange, {estilo} aesthetic, {key_detectada} mood, 8k."
 
 
 
 
 
43
 
44
- # Informe formateado con cuidado para evitar errores de llaves
45
- info_final = f"TONALIDAD: {key_detectada}\nESTILO: {estilo}\n\nCOMPARATIVA: {comparativa}\n\nCONSEJO: En {key_detectada}, el sub debe ser muy preciso
 
6
 
7
  def ghost_ultimate_v7(tu_track, track_ref, intensidad, duda):
8
  if tu_track is None:
9
+ return None, "Sube tu audio.", "Esperando...", "https://images.unsplash.com/photo-1614613535308-eb5fbd3d2c17?q=80&w=500", "Sube audio."
10
 
11
  try:
12
+ # 1. ANALISIS
13
  y, sr = librosa.load(tu_track, duration=30)
 
 
14
  chroma = librosa.feature.chroma_cqt(y=y, sr=sr)
15
  key_idx = np.argmax(np.mean(chroma, axis=1))
16
+ notas = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
17
+ key_det = notas[key_idx]
 
18
 
 
19
  rms_tu = np.mean(librosa.feature.rms(y=y))
20
+ estilo = "Dark Tech" if rms_tu > 0.12 else "Liquid"
21
 
22
  # 2. COMPARADOR
23
+ comp_txt = "No hay referencia."
24
  if track_ref is not None:
25
  y_ref, _ = librosa.load(track_ref, duration=30)
26
  rms_ref = np.mean(librosa.feature.rms(y=y_ref))
27
+ diff = 20 * np.log10(rms_ref / rms_tu)
28
+ comp_txt = "Diferencia de volumen: " + str(round(diff, 1)) + " dB"
29
 
30
  # 3. MASTERING
31
  sound = AudioSegment.from_file(tu_track)
32
+ gain = (intensidad / 10) - 5
33
+ mastered = sound.apply_gain(gain)
34
+ out = "master_v7.wav"
35
+ mastered.export(out, format="wav")
36
 
37
+ # 4. INFORME (Usando suma de textos para evitar errores de llaves {})
38
+ info = "TONALIDAD: " + key_det + "\n"
39
+ info += "ESTILO: " + estilo + "\n\n"
40
+ info += "COMPARATIVA: " + comp_txt + "\n\n"
41
+ info += "CONSEJO: En " + key_det + " el sub debe ser afinado."
42
+
43
+ prompt = "Cyberpunk DnB Art, Neon, " + estilo + " vibes, " + key_det + " mood."
44
 
45
+ return out, info, key_det + " | " + estilo