CVNSS commited on
Commit
5070a6e
·
verified ·
1 Parent(s): 7226c9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -71,6 +71,7 @@ SPEECH_END = "<|SPEECH_GENERATION_END|>"
71
 
72
  # Thiết bị xử lý
73
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
 
74
  DTYPE = torch.bfloat16 if DEVICE == "cuda" else torch.float32
75
 
76
  # ==========================================
@@ -90,9 +91,10 @@ def load_models():
90
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
91
 
92
  if model is None:
 
93
  model = AutoModelForCausalLM.from_pretrained(
94
  MODEL_ID,
95
- torch_dtype=DTYPE,
96
  trust_remote_code=True,
97
  ).to(DEVICE)
98
  model.eval()
@@ -302,7 +304,8 @@ css = """
302
  .note-box { background-color: #f0f9ff; border-left: 5px solid #00b4d8; padding: 15px; border-radius: 5px; margin-bottom: 20px; }
303
  """
304
 
305
- with gr.Blocks(title="Expert Voice Cloning - NeuTTS (Auto-Fix Build)", css=css, theme=gr.themes.Soft()) as demo:
 
306
 
307
  gr.Markdown("# 🎙️ Clone Giọng Nói Tiếng Việt (NeuTTS-Air Refactored)")
308
 
@@ -363,12 +366,12 @@ with gr.Blocks(title="Expert Voice Cloning - NeuTTS (Auto-Fix Build)", css=css,
363
  btn_generate = gr.Button("🚀 Tạo giọng nói (Start Cloning)", variant="primary", size="lg")
364
 
365
  gr.Markdown("### 3. Kết quả")
366
- # Output Audio có sẵn chức năng Download
 
367
  audio_output = gr.Audio(
368
- label="Audio đã tạo (Có nút tải về bên góc)",
369
  type="filepath",
370
- interactive=False, # Output mode
371
- show_download_button=True # Đảm bảo hiện nút download
372
  )
373
 
374
  # SỰ KIỆN
@@ -379,4 +382,9 @@ with gr.Blocks(title="Expert Voice Cloning - NeuTTS (Auto-Fix Build)", css=css,
379
  )
380
 
381
  if __name__ == "__main__":
382
- demo.queue().launch(share=False) # Đặt share=True nếu muốn public link
 
 
 
 
 
 
71
 
72
  # Thiết bị xử lý
73
  DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
74
+ # Gradio 6/Latest Transformers warning fix: use dtype instead of torch_dtype if warned
75
  DTYPE = torch.bfloat16 if DEVICE == "cuda" else torch.float32
76
 
77
  # ==========================================
 
91
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
92
 
93
  if model is None:
94
+ # FIX: Thay torch_dtype bằng dtype theo warning log
95
  model = AutoModelForCausalLM.from_pretrained(
96
  MODEL_ID,
97
+ dtype=DTYPE,
98
  trust_remote_code=True,
99
  ).to(DEVICE)
100
  model.eval()
 
304
  .note-box { background-color: #f0f9ff; border-left: 5px solid #00b4d8; padding: 15px; border-radius: 5px; margin-bottom: 20px; }
305
  """
306
 
307
+ # FIX: Xóa css theme khỏi constructor Blocks (Gradio 6.0 compatibility)
308
+ with gr.Blocks(title="Expert Voice Cloning - NeuTTS (Auto-Fix Build)") as demo:
309
 
310
  gr.Markdown("# 🎙️ Clone Giọng Nói Tiếng Việt (NeuTTS-Air Refactored)")
311
 
 
366
  btn_generate = gr.Button("🚀 Tạo giọng nói (Start Cloning)", variant="primary", size="lg")
367
 
368
  gr.Markdown("### 3. Kết quả")
369
+
370
+ # FIX: Xóa tham số show_download_button=True (Gradio 6.0 error fix)
371
  audio_output = gr.Audio(
372
+ label="Audio đã tạo",
373
  type="filepath",
374
+ interactive=False # Output mode
 
375
  )
376
 
377
  # SỰ KIỆN
 
382
  )
383
 
384
  if __name__ == "__main__":
385
+ # FIX: Chuyển theme css vào launch()
386
+ demo.queue().launch(
387
+ share=False,
388
+ theme=gr.themes.Soft(),
389
+ css=css
390
+ )