farid678 commited on
Commit
540093e
·
verified ·
1 Parent(s): 921b259

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -22,7 +22,7 @@ device = 0 if torch.cuda.is_available() else -1
22
  # -----------------------------
23
  # PATH TO FINE-TUNED MODEL
24
  # -----------------------------
25
- model_dir = "./" # مسیر فایل‌های fine-tuned در Space
26
 
27
  # -----------------------------
28
  # LOAD TTS PIPELINE
@@ -48,6 +48,10 @@ def tts_generate(text):
48
 
49
  audio = np.array(output["audio"], dtype=np.float32)
50
 
 
 
 
 
51
  # بررسی و مقدار پیش‌فرض sampling rate
52
  sr = output.get("sampling_rate") or 22050
53
 
@@ -91,4 +95,4 @@ demo = gr.Interface(
91
  # CLEAN RUN
92
  # -----------------------------
93
  if __name__ == "__main__":
94
- demo.launch(ssr_mode=False) # ssr_mode=False برای کاهش خطاهای asyncio
 
22
  # -----------------------------
23
  # PATH TO FINE-TUNED MODEL
24
  # -----------------------------
25
+ model_dir = "./" # مسیر فایل‌های fine-tuned Orpheus در Space
26
 
27
  # -----------------------------
28
  # LOAD TTS PIPELINE
 
48
 
49
  audio = np.array(output["audio"], dtype=np.float32)
50
 
51
+ # sanitize audio to avoid RuntimeWarning
52
+ audio = np.nan_to_num(audio) # convert NaN/Inf to 0
53
+ audio = np.clip(audio, -1.0, 1.0) # limit values to [-1,1]
54
+
55
  # بررسی و مقدار پیش‌فرض sampling rate
56
  sr = output.get("sampling_rate") or 22050
57
 
 
95
  # CLEAN RUN
96
  # -----------------------------
97
  if __name__ == "__main__":
98
+ demo.launch(ssr_mode=False) # کاهش خطاهای asyncio / Invalid file descriptor