File size: 1,862 Bytes
632f309
 
 
612247e
632f309
 
 
 
 
 
 
5e81135
 
2c09dca
5e81135
 
 
 
 
 
 
 
 
 
 
 
dbc81ba
0453296
 
 
 
632f309
0453296
8371e66
0453296
 
 
7c03ad2
 
 
 
 
 
0453296
612247e
632f309
612247e
 
 
 
 
ee145fd
612247e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from utils.hparams import hparams
from preprocessing.data_gen_utils import get_pitch_parselmouth,get_pitch_crepe
import numpy as np
import matplotlib.pyplot as plt
import IPython.display as ipd
import utils
import librosa
import torchcrepe
from infer import *
import logging
from infer_tools.infer_tool import *
import gradio as gr
import transformers
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# define the input interface for the app
inputs = gr.inputs.Textbox(lines=1, label="Enter a link:")
inputs += gr.inputs.Audio(label="Upload a WAV file:")

# define the output interface for the app
outputs = gr.outputs.Textbox(lines=1, label="Diff-SVC prediction:")

# define the app itself
app = gr.Interface(model, inputs, outputs, title="DIFF-SVC Inference Cloud")

# run the app
app.launch()

##EDIT FOR CPU
# Open the file and read it into a string
with open("/home/user/.local/lib/python3.8/site-packages/torch/serialization.py") as f:
    text = f.read()

# Replace the original line with the new line
text = text.replace("def load(f, map_location=None, pickle_module=pickle, **pickle_load_args):", "def load(f, map_location='cpu', pickle_module=pickle, **pickle_load_args):")
# Save the modified string to the original file
with open("/home/user/.local/lib/python3.8/site-packages/torch/serialization.py", "w") as f:
    f.write(text)

print("Replaced")
with open("/home/user/.local/lib/python3.8/site-packages/torch/serialization.py") as f:
    text = f.read()
print(text)

############
logging.getLogger('numba').setLevel(logging.WARNING)

# 工程文件夹名,训练时用的那个
project_name = "Unnamed"
model_path = f'./checkpoints/Unnamed/model_ckpt_steps_192000.ckpt'
config_path=f'./checkpoints/Unnamed/config.yaml'
hubert_gpu=False
svc_model = Svc(project_name,config_path,hubert_gpu, model_path)
print('model loaded')