Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,24 @@
|
|
1 |
-
import gradio as gr
|
2 |
import os
|
3 |
import torch
|
4 |
-
|
5 |
-
from TTS.tts.configs.xtts_config import XttsConfig
|
|
|
6 |
from TTS.api import TTS
|
7 |
|
8 |
# β
Accept Coqui License Automatically
|
9 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
10 |
|
11 |
# β
Fix PyTorch deserialization issue
|
12 |
-
torch.serialization.add_safe_globals([XttsAudioConfig]) # β
|
|
|
|
|
|
|
|
|
13 |
|
|
|
|
|
|
|
14 |
|
15 |
-
# Load the voice cloning model
|
16 |
-
tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to("cpu")
|
17 |
|
18 |
def generate_cloned_voice(text, reference_audio, language):
|
19 |
output_path = "output.wav"
|
|
|
|
|
1 |
import os
|
2 |
import torch
|
3 |
+
import gradio as gr
|
4 |
+
from TTS.tts.configs.xtts_config import XttsConfig # β
Import missing class
|
5 |
+
from TTS.tts.models.xtts import XttsAudioConfig # β
Import missing class
|
6 |
from TTS.api import TTS
|
7 |
|
8 |
# β
Accept Coqui License Automatically
|
9 |
os.environ["COQUI_TOS_AGREED"] = "1"
|
10 |
|
11 |
# β
Fix PyTorch deserialization issue
|
12 |
+
torch.serialization.add_safe_globals([XttsConfig, XttsAudioConfig]) # β
Allow both classes
|
13 |
+
|
14 |
+
# β
Force full checkpoint loading
|
15 |
+
def safe_load_checkpoint(model_path):
|
16 |
+
return torch.load(model_path, map_location="cpu", weights_only=False) # β
Force full deserialization
|
17 |
|
18 |
+
# β
Initialize TTS model
|
19 |
+
model_name = "tts_models/multilingual/multi-dataset/xtts_v2"
|
20 |
+
tts = TTS(model_name=model_name).to("cpu") # β
Ensure CPU usage
|
21 |
|
|
|
|
|
22 |
|
23 |
def generate_cloned_voice(text, reference_audio, language):
|
24 |
output_path = "output.wav"
|