Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,9 +4,24 @@ import numpy as np
|
|
| 4 |
import scipy.io.wavfile
|
| 5 |
from transformers import VitsModel, AutoTokenizer
|
| 6 |
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Load model and tokenizer
|
| 9 |
-
|
|
|
|
| 10 |
tokenizer = AutoTokenizer.from_pretrained("saleolow/somali-mms-tts")
|
| 11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 12 |
model.to(device)
|
|
@@ -203,4 +218,4 @@ gr.Interface(
|
|
| 203 |
outputs=gr.Audio(label="Codka TTS"),
|
| 204 |
title="Somali TTS",
|
| 205 |
description="Ku qor qoraal Soomaaliyeed si aad u maqasho cod dabiici ah. Qoraalka ha ka badnaan 2 daqiiqo per jumlad."
|
| 206 |
-
).launch()
|
|
|
|
| 4 |
import scipy.io.wavfile
|
| 5 |
from transformers import VitsModel, AutoTokenizer
|
| 6 |
import re
|
| 7 |
+
import os
|
| 8 |
+
import shutil
|
| 9 |
+
|
| 10 |
+
# --- ADDITIONAL CODE TO FIX STORAGE ERROR ---
|
| 11 |
+
# This clears the Hugging Face cache to free up the 50GB disk space limit
|
| 12 |
+
cache_path = os.path.expanduser("~/.cache/huggingface")
|
| 13 |
+
if os.path.exists(cache_path):
|
| 14 |
+
try:
|
| 15 |
+
shutil.rmtree(cache_path)
|
| 16 |
+
os.makedirs(cache_path)
|
| 17 |
+
print("Cache cleared successfully to free up storage.")
|
| 18 |
+
except Exception as e:
|
| 19 |
+
print(f"Note: Could not clear cache: {e}")
|
| 20 |
+
# ---------------------------------------------
|
| 21 |
|
| 22 |
# Load model and tokenizer
|
| 23 |
+
# Added low_cpu_mem_usage=True to help with Space stability
|
| 24 |
+
model = VitsModel.from_pretrained("Somali-tts/somali_tts_model", low_cpu_mem_usage=True)
|
| 25 |
tokenizer = AutoTokenizer.from_pretrained("saleolow/somali-mms-tts")
|
| 26 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 27 |
model.to(device)
|
|
|
|
| 218 |
outputs=gr.Audio(label="Codka TTS"),
|
| 219 |
title="Somali TTS",
|
| 220 |
description="Ku qor qoraal Soomaaliyeed si aad u maqasho cod dabiici ah. Qoraalka ha ka badnaan 2 daqiiqo per jumlad."
|
| 221 |
+
).launch()
|