SohomToom commited on
Commit
49c7767
·
verified ·
1 Parent(s): b4ad83e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -3
app.py CHANGED
@@ -1,11 +1,25 @@
1
  import os
2
- import gradio as gr
 
 
3
  os.environ["TORCH_HOME"] = "/tmp/torch"
4
  os.makedirs("/tmp/torch", exist_ok=True)
5
- import torch
6
- torch.hub.load(repo_or_dir="snakers4/silero-vad", model="silero_vad", trust_repo=True)
 
 
 
 
 
 
 
7
  from openvoice import se_extractor
8
  from openvoice.api import ToneColorConverter
 
 
 
 
 
9
  import time
10
  import uuid
11
 
 
1
  import os
2
+ import torch
3
+
4
+ # Set a writable cache directory for torch and preload Silero VAD
5
  os.environ["TORCH_HOME"] = "/tmp/torch"
6
  os.makedirs("/tmp/torch", exist_ok=True)
7
+
8
+ # Preload Silero VAD to avoid runtime issues
9
+ try:
10
+ torch.hub.load(repo_or_dir="snakers4/silero-vad", model="silero_vad", trust_repo=True)
11
+ print("Silero VAD model preloaded successfully.")
12
+ except Exception as e:
13
+ print(f"Failed to preload Silero VAD: {e}")
14
+
15
+ # Now proceed with the rest of the imports
16
  from openvoice import se_extractor
17
  from openvoice.api import ToneColorConverter
18
+ from openvoice.config import AttrDict
19
+ import gradio as gr
20
+ import torchaudio
21
+ # ... other imports if needed
22
+
23
  import time
24
  import uuid
25