SefyanKehail commited on
Commit
490051a
·
1 Parent(s): 285d7b1

cuda process in main thread issue

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -3,10 +3,6 @@ import requests
3
  import IPython.display as display
4
  import gradio as gr
5
  import multiprocessing
6
-
7
- device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
8
-
9
-
10
  # Function to initialize models with CUDA
11
  def initialize_models():
12
  hubert = torch.hub.load("bshall/hubert:main", "hubert_soft", trust_repo=True).cuda()
@@ -14,7 +10,7 @@ def initialize_models():
14
  hifigan = torch.hub.load("bshall/hifigan:main", "hifigan_hubert_soft", trust_repo=True).cuda()
15
  return hubert, acoustic, hifigan
16
 
17
- hubert, acoustic, hifigan = initialize_models()
18
 
19
  # Conversion function
20
  def convert_speech(filename, progress=gr.Progress()):
@@ -36,6 +32,7 @@ def convert_speech(filename, progress=gr.Progress()):
36
 
37
  # Convert to the target speaker:
38
  with torch.inference_mode():
 
39
  # Extract speech units
40
  units = hubert.units(source)
41
  # Generate target spectrogram
 
3
  import IPython.display as display
4
  import gradio as gr
5
  import multiprocessing
 
 
 
 
6
  # Function to initialize models with CUDA
7
  def initialize_models():
8
  hubert = torch.hub.load("bshall/hubert:main", "hubert_soft", trust_repo=True).cuda()
 
10
  hifigan = torch.hub.load("bshall/hifigan:main", "hifigan_hubert_soft", trust_repo=True).cuda()
11
  return hubert, acoustic, hifigan
12
 
13
+
14
 
15
  # Conversion function
16
  def convert_speech(filename, progress=gr.Progress()):
 
32
 
33
  # Convert to the target speaker:
34
  with torch.inference_mode():
35
+ hubert, acoustic, hifigan = initialize_models()
36
  # Extract speech units
37
  units = hubert.units(source)
38
  # Generate target spectrogram