Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import gradio as gr
|
| 3 |
from chatterbox_vc import VoiceConverter
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
print(f"Using device: {device}")
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def convert(source_audio, target_audio):
|
| 13 |
if source_audio is None:
|
| 14 |
raise gr.Error("Please upload a source audio file.")
|
|
@@ -18,7 +27,9 @@ def convert(source_audio, target_audio):
|
|
| 18 |
|
| 19 |
output = "output.wav"
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
source_audio,
|
| 23 |
target_audio,
|
| 24 |
output,
|
|
@@ -54,4 +65,5 @@ with gr.Blocks() as demo:
|
|
| 54 |
outputs=output,
|
| 55 |
)
|
| 56 |
|
|
|
|
| 57 |
demo.launch()
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
import torch
|
| 3 |
import gradio as gr
|
| 4 |
from chatterbox_vc import VoiceConverter
|
| 5 |
|
| 6 |
+
vc = None
|
| 7 |
|
|
|
|
| 8 |
|
| 9 |
+
def get_converter():
|
| 10 |
+
global vc
|
| 11 |
|
| 12 |
+
if vc is None:
|
| 13 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 14 |
+
print(f"Loading ChatterboxVC on {device}...")
|
| 15 |
+
vc = VoiceConverter(device=device)
|
| 16 |
|
| 17 |
+
return vc
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
@spaces.GPU
|
| 21 |
def convert(source_audio, target_audio):
|
| 22 |
if source_audio is None:
|
| 23 |
raise gr.Error("Please upload a source audio file.")
|
|
|
|
| 27 |
|
| 28 |
output = "output.wav"
|
| 29 |
|
| 30 |
+
converter = get_converter()
|
| 31 |
+
|
| 32 |
+
converter.convert(
|
| 33 |
source_audio,
|
| 34 |
target_audio,
|
| 35 |
output,
|
|
|
|
| 65 |
outputs=output,
|
| 66 |
)
|
| 67 |
|
| 68 |
+
|
| 69 |
demo.launch()
|