ginipick commited on
Commit
bddc80f
·
verified ·
1 Parent(s): c8a3a02

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -262,9 +262,9 @@ def infer(genre_txt_content, lyrics_txt_content, num_segments, max_new_tokens):
262
  logging.info(f"Selected model: {model_path}")
263
  logging.info(f"Lyrics analysis: {params}")
264
 
265
- # 코러스 섹션 확인
266
  has_chorus = params['sections']['chorus'] > 0
267
- estimated_duration = params.get('estimated_duration', 60) # 기본값 60초
268
 
269
  logging.info(f"Estimated duration: {estimated_duration} seconds")
270
  logging.info(f"Has chorus sections: {has_chorus}")
@@ -283,7 +283,7 @@ def infer(genre_txt_content, lyrics_txt_content, num_segments, max_new_tokens):
283
  os.makedirs(output_dir, exist_ok=True)
284
  empty_output_folder(output_dir)
285
 
286
- # 기본 명령어 구성
287
  command = [
288
  "python", "infer.py",
289
  "--stage1_model", model_path,
@@ -294,16 +294,9 @@ def infer(genre_txt_content, lyrics_txt_content, num_segments, max_new_tokens):
294
  "--stage2_batch_size", str(config['batch_size']),
295
  "--output_dir", output_dir,
296
  "--cuda_idx", "0",
297
- "--max_new_tokens", str(actual_max_tokens),
298
- "--keep_intermediate"
299
  ]
300
 
301
- if has_chorus:
302
- command.extend([
303
- "--segment_duration", str(int(estimated_duration / actual_num_segments)),
304
- "--enhance_chorus"
305
- ])
306
-
307
  # GPU가 있는 경우에만 추가 옵션 적용
308
  if torch.cuda.is_available():
309
  command.append("--disable_offload_model")
@@ -348,11 +341,14 @@ def infer(genre_txt_content, lyrics_txt_content, num_segments, max_new_tokens):
348
  # 결과 처리
349
  last_mp3 = get_last_mp3_file(output_dir)
350
  if last_mp3:
351
- duration = get_audio_duration(last_mp3)
352
- logging.info(f"Generated audio file: {last_mp3}")
353
- if duration:
354
- logging.info(f"Audio duration: {duration:.2f} seconds")
355
- logging.info(f"Expected duration: {estimated_duration} seconds")
 
 
 
356
  return last_mp3
357
  else:
358
  logging.warning("No output audio file generated")
 
262
  logging.info(f"Selected model: {model_path}")
263
  logging.info(f"Lyrics analysis: {params}")
264
 
265
+ # 코러스 섹션 확인 및 로깅
266
  has_chorus = params['sections']['chorus'] > 0
267
+ estimated_duration = params.get('estimated_duration', 60)
268
 
269
  logging.info(f"Estimated duration: {estimated_duration} seconds")
270
  logging.info(f"Has chorus sections: {has_chorus}")
 
283
  os.makedirs(output_dir, exist_ok=True)
284
  empty_output_folder(output_dir)
285
 
286
+ # 기본 명령어 구성 (지원되는 매개변수만 사용)
287
  command = [
288
  "python", "infer.py",
289
  "--stage1_model", model_path,
 
294
  "--stage2_batch_size", str(config['batch_size']),
295
  "--output_dir", output_dir,
296
  "--cuda_idx", "0",
297
+ "--max_new_tokens", str(actual_max_tokens)
 
298
  ]
299
 
 
 
 
 
 
 
300
  # GPU가 있는 경우에만 추가 옵션 적용
301
  if torch.cuda.is_available():
302
  command.append("--disable_offload_model")
 
341
  # 결과 처리
342
  last_mp3 = get_last_mp3_file(output_dir)
343
  if last_mp3:
344
+ try:
345
+ duration = get_audio_duration(last_mp3)
346
+ logging.info(f"Generated audio file: {last_mp3}")
347
+ if duration:
348
+ logging.info(f"Audio duration: {duration:.2f} seconds")
349
+ logging.info(f"Expected duration: {estimated_duration} seconds")
350
+ except Exception as e:
351
+ logging.warning(f"Failed to get audio duration: {e}")
352
  return last_mp3
353
  else:
354
  logging.warning("No output audio file generated")