Spaces:
Configuration error
Configuration error
Kangarroar
commited on
Commit
•
4d5522d
1
Parent(s):
918c9e3
Delete streamlitpoe.py
Browse files- streamlitpoe.py +0 -100
streamlitpoe.py
DELETED
@@ -1,100 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
-
import numpy as np
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
-
import json
|
6 |
-
import tempfile
|
7 |
-
import shutil
|
8 |
-
temp_dir = tempfile.mkdtemp()
|
9 |
-
global ckpt_temp_file
|
10 |
-
global audio_temp_file
|
11 |
-
global config_temp_file
|
12 |
-
###################################################
|
13 |
-
from utils.hparams import hparams
|
14 |
-
from preprocessing.data_gen_utils import get_pitch_parselmouth,get_pitch_crepe
|
15 |
-
import numpy as np
|
16 |
-
import matplotlib.pyplot as plt
|
17 |
-
import IPython.display as ipd
|
18 |
-
import utils
|
19 |
-
import librosa
|
20 |
-
import torchcrepe
|
21 |
-
from infer import *
|
22 |
-
import logging
|
23 |
-
from infer_tools.infer_tool import *
|
24 |
-
import io
|
25 |
-
clip_completed = False
|
26 |
-
def render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title):
|
27 |
-
logging.getLogger('numba').setLevel(logging.WARNING)
|
28 |
-
title = int(title)
|
29 |
-
project_name = "Unnamed"
|
30 |
-
model_path = ckpt_temp_file
|
31 |
-
config_path= config_temp_file
|
32 |
-
hubert_gpu=True
|
33 |
-
svc_model = Svc(project_name,config_path,hubert_gpu, model_path)
|
34 |
-
print('model loaded')
|
35 |
-
wav_fn = audio_temp_file
|
36 |
-
demoaudio, sr = librosa.load(wav_fn)
|
37 |
-
key = title # 音高调整,支持正负(半音)
|
38 |
-
# 加速倍数
|
39 |
-
|
40 |
-
pndm_speedup = 20
|
41 |
-
wav_gen='queeeeee.wav'#直接改后缀可以保存不同格式音频,如flac可无损压缩
|
42 |
-
f0_tst, f0_pred, audio = run_clip(svc_model,file_path=wav_fn, key=key, acc=pndm_speedup, use_crepe=True, use_pe=True, thre=0.05,
|
43 |
-
use_gt_mel=False, add_noise_step=500,project_name=project_name,out_path=wav_gen)
|
44 |
-
clip_completed = True
|
45 |
-
if clip_completed:
|
46 |
-
# If the 'run_clip' function has completed, use the st.audio function to show an audio player for the file stored in the 'wav_gen' variable
|
47 |
-
st.audio(wav_gen)
|
48 |
-
#######################################################
|
49 |
-
st.set_page_config(
|
50 |
-
page_title="DiffSVC Render",
|
51 |
-
page_icon="🧊",
|
52 |
-
initial_sidebar_state="expanded",
|
53 |
-
)
|
54 |
-
############
|
55 |
-
st.title('DIFF-SVC Render')
|
56 |
-
|
57 |
-
###CKPT LOADER
|
58 |
-
ckpt = st.file_uploader("Choose your CKPT", type= 'ckpt')
|
59 |
-
# Check if user uploaded a CKPT file
|
60 |
-
if ckpt is not None:
|
61 |
-
#TEMP FUNCTION
|
62 |
-
with tempfile.NamedTemporaryFile(mode="wb", suffix='.ckpt', delete=False) as temp:
|
63 |
-
# Get the file contents as bytes
|
64 |
-
bytes_data = ckpt.getvalue()
|
65 |
-
# Write the bytes to the temporary file
|
66 |
-
temp.write(bytes_data)
|
67 |
-
ckpt_temp_file = temp.name
|
68 |
-
# Print the temporary file name
|
69 |
-
print(temp.name)
|
70 |
-
|
71 |
-
###CONFIG LOADER
|
72 |
-
config = st.file_uploader("Choose your config", type= 'yaml')
|
73 |
-
if config is not None:
|
74 |
-
#TEMP FUNCTION
|
75 |
-
with tempfile.NamedTemporaryFile(mode="wb", suffix='.yaml', delete=False) as temp:
|
76 |
-
# Get the file contents as bytes
|
77 |
-
bytes_data = config.getvalue()
|
78 |
-
# Write the bytes to the temporary file
|
79 |
-
temp.write(bytes_data)
|
80 |
-
config_temp_file = temp.name
|
81 |
-
# Print the temporary file name
|
82 |
-
print(temp.name)
|
83 |
-
|
84 |
-
##WAV LOADER
|
85 |
-
audio = st.file_uploader("Choose your audio", type= 'wav' or 'mp3')
|
86 |
-
if audio is not None:
|
87 |
-
#TEMP FUNCTION
|
88 |
-
with tempfile.NamedTemporaryFile(mode="wb", suffix='.wav', delete=False) as temp:
|
89 |
-
# Get the file contents as bytes
|
90 |
-
bytes_data = audio.getvalue()
|
91 |
-
# Write the bytes to the temporary file
|
92 |
-
temp.write(bytes_data)
|
93 |
-
audio_temp_file = temp.name
|
94 |
-
# Print the temporary file name
|
95 |
-
print(temp.name)
|
96 |
-
title = st.text_input('Key', '0')
|
97 |
-
gflag = st.slider('Gender Flag', 0.80, 1.20, 1.00)
|
98 |
-
|
99 |
-
###DOWNLOAD
|
100 |
-
st.button('Render', on_click=render_audio(ckpt_temp_file, config_temp_file, audio_temp_file, title))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|