Spaces:
Running
on
Zero
Running
on
Zero
TheStinger
commited on
Commit
•
aa7549b
1
Parent(s):
5f5ae6a
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ os.environ["no_proxy"] = "localhost, 127.0.0.1, ::1"
|
|
4 |
import threading
|
5 |
from time import sleep
|
6 |
from subprocess import Popen
|
7 |
-
from typing import Any
|
8 |
import faiss
|
9 |
import spaces
|
10 |
from random import shuffle
|
@@ -195,7 +194,6 @@ else:
|
|
195 |
or "M4" in gpu_name.upper()
|
196 |
or "T4" in gpu_name.upper()
|
197 |
or "TITAN" in gpu_name.upper()
|
198 |
-
or "ZERO" in gpu_name.upper()
|
199 |
): # A10#A100#V100#A40#P40#M40#K80#A4500
|
200 |
if_gpu_ok = True # 至少有一张能用的N卡
|
201 |
gpu_infos.append("%s\t%s" % (i, gpu_name))
|
@@ -222,31 +220,30 @@ from lib.infer_pack.models import (
|
|
222 |
SynthesizerTrnMs768NSFsid_nono,
|
223 |
)
|
224 |
import soundfile as sf
|
225 |
-
from fairseq import checkpoint_utils
|
226 |
import gradio as gr
|
227 |
import logging
|
228 |
from vc_infer_pipeline import VC
|
229 |
from config import Config
|
|
|
|
|
230 |
|
231 |
config = Config()
|
232 |
# from trainset_preprocess_pipeline import PreProcess
|
233 |
logging.getLogger("numba").setLevel(logging.WARNING)
|
234 |
|
235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
def load_hubert():
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
suffix="",
|
242 |
-
)
|
243 |
-
hubert_model = models[0]
|
244 |
-
hubert_model = hubert_model.to(config.device)
|
245 |
-
if config.is_half:
|
246 |
-
hubert_model = hubert_model.half()
|
247 |
-
else:
|
248 |
-
hubert_model = hubert_model.float()
|
249 |
-
hubert_model.eval()
|
250 |
|
251 |
|
252 |
weight_root = "weights"
|
@@ -262,7 +259,7 @@ for root, dirs, files in os.walk(index_root, topdown=False):
|
|
262 |
index_paths.append("%s/%s" % (root, name))
|
263 |
|
264 |
|
265 |
-
|
266 |
def vc_single(
|
267 |
sid,
|
268 |
input_audio_path,
|
|
|
4 |
import threading
|
5 |
from time import sleep
|
6 |
from subprocess import Popen
|
|
|
7 |
import faiss
|
8 |
import spaces
|
9 |
from random import shuffle
|
|
|
194 |
or "M4" in gpu_name.upper()
|
195 |
or "T4" in gpu_name.upper()
|
196 |
or "TITAN" in gpu_name.upper()
|
|
|
197 |
): # A10#A100#V100#A40#P40#M40#K80#A4500
|
198 |
if_gpu_ok = True # 至少有一张能用的N卡
|
199 |
gpu_infos.append("%s\t%s" % (i, gpu_name))
|
|
|
220 |
SynthesizerTrnMs768NSFsid_nono,
|
221 |
)
|
222 |
import soundfile as sf
|
|
|
223 |
import gradio as gr
|
224 |
import logging
|
225 |
from vc_infer_pipeline import VC
|
226 |
from config import Config
|
227 |
+
import torch.nn as nn
|
228 |
+
import numpy as np
|
229 |
|
230 |
config = Config()
|
231 |
# from trainset_preprocess_pipeline import PreProcess
|
232 |
logging.getLogger("numba").setLevel(logging.WARNING)
|
233 |
|
234 |
+
|
235 |
+
class HuBERT(nn.Module):
|
236 |
+
def __init__(self, model_path):
|
237 |
+
super(HuBERT, self).__init__()
|
238 |
+
self.model = torch.hub.load('pytorch/fairseq', 'hubert_base') # should load without using hubert_base.pt, and without fairseq.
|
239 |
+
|
240 |
+
def extract_features(self, waveform):
|
241 |
+
return self.model.extract_features(waveform)
|
242 |
|
243 |
def load_hubert():
|
244 |
+
model_path = "hubert_base.pt" # Your model path
|
245 |
+
hubert_model = HuBERT(model_path)
|
246 |
+
return hubert_model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
|
249 |
weight_root = "weights"
|
|
|
259 |
index_paths.append("%s/%s" % (root, name))
|
260 |
|
261 |
|
262 |
+
|
263 |
def vc_single(
|
264 |
sid,
|
265 |
input_audio_path,
|