KiranRand commited on
Commit
3cf914c
Β·
verified Β·
1 Parent(s): 725bb8a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -21
app.py CHANGED
@@ -1,40 +1,25 @@
1
  import os
2
  import torch
3
  import gradio as gr
4
- from TTS.tts.models.xtts import XttsArgs
5
-
6
  from TTS.api import TTS
7
 
8
-
9
  # βœ… Accept Coqui License Automatically
10
  os.environ["COQUI_TOS_AGREED"] = "1"
11
 
 
 
12
 
13
- torch.serialization.safe_globals([XttsArgs])
14
- torch.serialization.add_safe_globals([XttsConfig])
15
-
16
- # βœ… Force full checkpoint loading
17
- def safe_load_checkpoint(model_path):
18
- return torch.load(model_path, map_location="cpu", weights_only=False) # βœ… Force full deserialization
19
-
20
- # βœ… Initialize TTS model
21
  model_name = "tts_models/multilingual/multi-dataset/xtts_v2"
22
- tts = TTS(model_name=model_name).to("cpu") # βœ… Ensure CPU usage
 
 
23
 
24
 
25
- # βœ… Accept Coqui License Automatically
26
- os.environ["COQUI_TOS_AGREED"] = "1"
27
 
28
 
29
- torch.serialization.safe_globals([XttsArgs])
30
 
31
- # βœ… Force full checkpoint loading
32
- def safe_load_checkpoint(model_path):
33
- return torch.load(model_path, map_location="cpu", weights_only=False) # βœ… Force full deserialization
34
 
35
- # βœ… Initialize TTS model
36
- model_name = "tts_models/multilingual/multi-dataset/xtts_v2"
37
- tts = TTS(model_name=model_name).to("cpu") # βœ… Ensure CPU usage
38
 
39
 
40
 
 
1
  import os
2
  import torch
3
  import gradio as gr
 
 
4
  from TTS.api import TTS
5
 
 
6
  # βœ… Accept Coqui License Automatically
7
  os.environ["COQUI_TOS_AGREED"] = "1"
8
 
9
+ # βœ… Ensure CPU-only execution (disable GPU)
10
+ device = "cpu"
11
 
12
+ # βœ… Manually Load XTTS Model (Without `XttsConfig`)
 
 
 
 
 
 
 
13
  model_name = "tts_models/multilingual/multi-dataset/xtts_v2"
14
+ model_path = f"{os.getenv('HOME')}/.local/share/tts/{model_name.replace('/', '--')}" # Custom model path
15
+
16
+ tts = TTS(model_name=model_name).to(device)
17
 
18
 
 
 
19
 
20
 
 
21
 
 
 
 
22
 
 
 
 
23
 
24
 
25