Spaces:
Running
on
Zero
Running
on
Zero
Update app_v1v2.py
Browse files- app_v1v2.py +3 -17
app_v1v2.py
CHANGED
@@ -24,11 +24,11 @@ if hasattr(torch._inductor.config, "fx_graph_cache"):
|
|
24 |
dtype = torch.float32
|
25 |
|
26 |
# Global variables to store model instances
|
27 |
-
vc_wrapper_v1 =
|
28 |
-
vc_wrapper_v2 =
|
29 |
|
30 |
|
31 |
-
def load_v2_models(
|
32 |
from hydra.utils import instantiate
|
33 |
from omegaconf import DictConfig
|
34 |
cfg = DictConfig(yaml.safe_load(open("configs/v2/vc_wrapper.yaml", "r")))
|
@@ -39,10 +39,6 @@ def load_v2_models(args):
|
|
39 |
|
40 |
vc_wrapper.setup_ar_caches(max_batch_size=1, max_seq_len=4096, dtype=dtype, device=device)
|
41 |
|
42 |
-
if args.compile:
|
43 |
-
vc_wrapper.compile_ar()
|
44 |
-
# vc_wrapper.compile_cfm()
|
45 |
-
|
46 |
return vc_wrapper
|
47 |
|
48 |
@spaces.GPU
|
@@ -52,9 +48,6 @@ def convert_voice_v1_wrapper(source_audio_path, target_audio_path, diffusion_ste
|
|
52 |
"""
|
53 |
Wrapper function for vc_wrapper.convert_voice that can be decorated with @spaces.GPU
|
54 |
"""
|
55 |
-
global vc_wrapper_v1
|
56 |
-
if vc_wrapper_v1 is None:
|
57 |
-
vc_wrapper_v1 = SeedVCWrapper()
|
58 |
|
59 |
# Use yield from to properly handle the generator
|
60 |
yield from vc_wrapper_v1.convert_voice(
|
@@ -77,13 +70,6 @@ def convert_voice_v2_wrapper(source_audio_path, target_audio_path, diffusion_ste
|
|
77 |
"""
|
78 |
Wrapper function for vc_wrapper.convert_voice_with_streaming that can be decorated with @spaces.GPU
|
79 |
"""
|
80 |
-
global vc_wrapper_v2
|
81 |
-
if vc_wrapper_v2 is None:
|
82 |
-
# Initialize with default arguments
|
83 |
-
parser = argparse.ArgumentParser()
|
84 |
-
parser.add_argument("--compile", type=bool, default=True)
|
85 |
-
args = parser.parse_args([])
|
86 |
-
vc_wrapper_v2 = load_v2_models(args)
|
87 |
|
88 |
# Use yield from to properly handle the generator
|
89 |
yield from vc_wrapper_v2.convert_voice_with_streaming(
|
|
|
24 |
dtype = torch.float32
|
25 |
|
26 |
# Global variables to store model instances
|
27 |
+
vc_wrapper_v1 = SeedVCWrapper()
|
28 |
+
vc_wrapper_v2 = load_v2_models(args)
|
29 |
|
30 |
|
31 |
+
def load_v2_models():
|
32 |
from hydra.utils import instantiate
|
33 |
from omegaconf import DictConfig
|
34 |
cfg = DictConfig(yaml.safe_load(open("configs/v2/vc_wrapper.yaml", "r")))
|
|
|
39 |
|
40 |
vc_wrapper.setup_ar_caches(max_batch_size=1, max_seq_len=4096, dtype=dtype, device=device)
|
41 |
|
|
|
|
|
|
|
|
|
42 |
return vc_wrapper
|
43 |
|
44 |
@spaces.GPU
|
|
|
48 |
"""
|
49 |
Wrapper function for vc_wrapper.convert_voice that can be decorated with @spaces.GPU
|
50 |
"""
|
|
|
|
|
|
|
51 |
|
52 |
# Use yield from to properly handle the generator
|
53 |
yield from vc_wrapper_v1.convert_voice(
|
|
|
70 |
"""
|
71 |
Wrapper function for vc_wrapper.convert_voice_with_streaming that can be decorated with @spaces.GPU
|
72 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Use yield from to properly handle the generator
|
75 |
yield from vc_wrapper_v2.convert_voice_with_streaming(
|