Hezu06 commited on
Commit
2247983
·
1 Parent(s): f16998c

update generate_ai_midi to print first 20 events and refine audio processing parameters

Browse files
Files changed (1) hide show
  1. main.py +5 -5
main.py CHANGED
@@ -137,7 +137,7 @@ def generate_ai_midi(bpm: int, output_file: str, num_notes: int = 200):
137
  pattern.append(index)
138
  pattern = pattern[1:]
139
 
140
- print("Sample notes:", generated_notes[:10])
141
 
142
  # ==========================================
143
  # 5. BUILD MIDI STREAM
@@ -204,7 +204,6 @@ def generate_ai_midi(bpm: int, output_file: str, num_notes: int = 200):
204
  continue
205
  final_stream = stream.Stream()
206
 
207
- # add instrument ONLY ONCE
208
  inst = instrument.Piano()
209
  inst.midiProgram = 0 # 🔥 Acoustic Grand Piano
210
  inst.midiChannel = 0 # 🔥 tránh channel 9 (drum)
@@ -258,14 +257,15 @@ async def generate_vibe(data: HeartRateData, request: Request):
258
  try:
259
  subprocess.run([
260
  "fluidsynth",
 
 
261
  "-ni", # Chạy ẩn không cần giao diện
262
  "-g", "1.5", # [NÂNG CẤP] Giảm âm lượng tổng để tiếng bớt "đanh"
263
  "-r", "44100", # Chất lượng Sample rate
264
  "--reverb", "yes", # [MỚI] Bật vang số để các nốt nối đuôi nhau (giảm rời rạc)
265
  "--chorus", "yes", # [MỚI] Làm dày âm thanh, tạo cảm giác êm ái hơn
266
- "-F", wav_file, # Xuất ra file thay vì phát ra loa laptop!
267
- soundfont_path, # Dàn nhạc (Soundfont)
268
- midi_file # Kịch bản (MIDI)
269
  ], check=True)
270
 
271
  # --- BƯỚC MỚI: LỌC ÂM THANH NHỨC ÓC ---
 
137
  pattern.append(index)
138
  pattern = pattern[1:]
139
 
140
+ print("First 20 events:", generated_notes[:20])
141
 
142
  # ==========================================
143
  # 5. BUILD MIDI STREAM
 
204
  continue
205
  final_stream = stream.Stream()
206
 
 
207
  inst = instrument.Piano()
208
  inst.midiProgram = 0 # 🔥 Acoustic Grand Piano
209
  inst.midiChannel = 0 # 🔥 tránh channel 9 (drum)
 
257
  try:
258
  subprocess.run([
259
  "fluidsynth",
260
+ soundfont_path,
261
+ midi_file, # Kịch bản (MIDI do AI tạo ra)
262
  "-ni", # Chạy ẩn không cần giao diện
263
  "-g", "1.5", # [NÂNG CẤP] Giảm âm lượng tổng để tiếng bớt "đanh"
264
  "-r", "44100", # Chất lượng Sample rate
265
  "--reverb", "yes", # [MỚI] Bật vang số để các nốt nối đuôi nhau (giảm rời rạc)
266
  "--chorus", "yes", # [MỚI] Làm dày âm thanh, tạo cảm giác êm ái hơn
267
+ "-F",
268
+ wav_file # Xuất ra file thay vì phát ra loa laptop!
 
269
  ], check=True)
270
 
271
  # --- BƯỚC MỚI: LỌC ÂM THANH NHỨC ÓC ---