Spaces:
Configuration error
Configuration error
Commit
·
612247e
1
Parent(s):
632f309
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,7 @@
|
|
| 1 |
-
import tkinter as tk
|
| 2 |
-
import tkinter.filedialog
|
| 3 |
-
import tkinter.ttk as ttk
|
| 4 |
-
import tkinter as tk
|
| 5 |
-
from tkinter import ttk
|
| 6 |
-
import wave
|
| 7 |
from utils.hparams import hparams
|
| 8 |
from preprocessing.data_gen_utils import get_pitch_parselmouth,get_pitch_crepe
|
| 9 |
import numpy as np
|
|
|
|
| 10 |
import IPython.display as ipd
|
| 11 |
import utils
|
| 12 |
import librosa
|
|
@@ -14,103 +9,13 @@ import torchcrepe
|
|
| 14 |
from infer import *
|
| 15 |
import logging
|
| 16 |
from infer_tools.infer_tool import *
|
| 17 |
-
from tkinter import Label
|
| 18 |
-
from time import sleep
|
| 19 |
-
import os
|
| 20 |
-
# Create the main window
|
| 21 |
-
window = tk.Tk()
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
loading_animation_label = Label(window)
|
| 33 |
-
loading_animation_label.grid(row=5, column=0)
|
| 34 |
-
|
| 35 |
-
# Set the column and row to stretch to fill the available space
|
| 36 |
-
window.grid_columnconfigure(0, weight=1)
|
| 37 |
-
window.grid_rowconfigure(4, weight=1)
|
| 38 |
-
|
| 39 |
-
button1 = ttk.Button(window, text="Load Model")
|
| 40 |
-
button1.grid(row=0, column=0, padx=20, pady=20)
|
| 41 |
-
|
| 42 |
-
pb = ttk.Progressbar(
|
| 43 |
-
window,
|
| 44 |
-
orient='horizontal',
|
| 45 |
-
mode='indeterminate',
|
| 46 |
-
length=250
|
| 47 |
-
)
|
| 48 |
-
def start():
|
| 49 |
-
pb.grid(column=0, row=5, padx=0, pady=0)
|
| 50 |
-
pb.start(10)
|
| 51 |
-
|
| 52 |
-
def stop():
|
| 53 |
-
pb.stop()
|
| 54 |
-
pb.grid_remove()
|
| 55 |
-
def button1_clicked():
|
| 56 |
-
filepath1 = tkinter.filedialog.askopenfilename(title = "Select CKPT File", filetypes=[("Checkpoint files", "*.ckpt")])
|
| 57 |
-
if filepath1 == '':
|
| 58 |
-
tkinter.messagebox.showerror("Error", "No CKPT file selected")
|
| 59 |
-
return
|
| 60 |
-
filepath2 = tkinter.filedialog.askopenfilename(title = "Select YAML File",filetypes=[("Yaml files", "*.yaml")])
|
| 61 |
-
if filepath2 == '':
|
| 62 |
-
tkinter.messagebox.showerror("Error", "No YAML file selected")
|
| 63 |
-
return
|
| 64 |
-
model_path = filepath1
|
| 65 |
-
config_path = filepath2
|
| 66 |
-
logging.getLogger('numba').setLevel(logging.WARNING)
|
| 67 |
-
start()
|
| 68 |
-
# Show a dialog box to input text
|
| 69 |
-
global project_name
|
| 70 |
-
project_name = tkinter.simpledialog.askstring("Input", "Enter project name:", parent=window)
|
| 71 |
-
if project_name == '':
|
| 72 |
-
tkinter.messagebox.showerror("Error", "No Project Name")
|
| 73 |
-
return
|
| 74 |
-
# Use the input text and the value of hubert_gpu as arguments when creating an instance of the Svc class
|
| 75 |
-
global svc_model
|
| 76 |
-
hubert_gpu = False
|
| 77 |
-
svc_model = Svc(project_name, config_path, hubert_gpu, model_path)
|
| 78 |
-
textbox.insert('end', 'model loaded\n')
|
| 79 |
-
stop()
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
# Assign the callback function to the button's "command" attribute
|
| 83 |
-
button1["command"] = button1_clicked
|
| 84 |
-
|
| 85 |
-
button2 = ttk.Button(window, text="Start Rendering")
|
| 86 |
-
button2.grid(row=1, column=0, padx=20, pady=20)
|
| 87 |
-
|
| 88 |
-
# Define a callback function for the second button
|
| 89 |
-
def button2_clicked():
|
| 90 |
-
# Open a file selection dialog for WAV files
|
| 91 |
-
filepath = tkinter.filedialog.askopenfilename(filetypes=[("WAV files", "*.wav")])
|
| 92 |
-
|
| 93 |
-
# Show a dialog box to input the "key" value
|
| 94 |
-
key = tkinter.simpledialog.askinteger("Input", "Enter key value:", parent=window)
|
| 95 |
-
textbox.insert('end', 'Rendering Started, please wait...\n')
|
| 96 |
-
start()
|
| 97 |
-
wav_gen = tkinter.simpledialog.askstring("Input", "Enter the track name:", parent=window)
|
| 98 |
-
if not wav_gen.endswith('.wav'):
|
| 99 |
-
wav_gen += '.wav'
|
| 100 |
-
wav_fn = filepath
|
| 101 |
-
demoaudio, sr = librosa.load(wav_fn)
|
| 102 |
-
pndm_speedup = 20
|
| 103 |
-
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,
|
| 104 |
-
use_gt_mel=False, add_noise_step=500,project_name=project_name,out_path=wav_gen)
|
| 105 |
-
time.sleep(2)
|
| 106 |
-
textbox.insert('end', 'Rendering process done!\nPlaying Audio now...')
|
| 107 |
-
os.startfile(wav_gen)
|
| 108 |
-
stop()
|
| 109 |
-
button2["command"] = button2_clicked
|
| 110 |
-
#Checkbox
|
| 111 |
-
hubert_gpu = tk.BooleanVar()
|
| 112 |
-
checkbox = tk.Checkbutton(window, text="Use GPU", variable=hubert_gpu)
|
| 113 |
-
checkbox.grid(row=3, column=0)
|
| 114 |
-
|
| 115 |
-
# Start the event loop
|
| 116 |
-
window.mainloop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from utils.hparams import hparams
|
| 2 |
from preprocessing.data_gen_utils import get_pitch_parselmouth,get_pitch_crepe
|
| 3 |
import numpy as np
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
import IPython.display as ipd
|
| 6 |
import utils
|
| 7 |
import librosa
|
|
|
|
| 9 |
from infer import *
|
| 10 |
import logging
|
| 11 |
from infer_tools.infer_tool import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
logging.getLogger('numba').setLevel(logging.WARNING)
|
| 14 |
|
| 15 |
+
# 工程文件夹名,训练时用的那个
|
| 16 |
+
project_name = "Unnamed"
|
| 17 |
+
model_path = f'./checkpoints/Unnamed/model_ckpt_steps_192000.ckpt'
|
| 18 |
+
config_path=f'./checkpoints/Unnamed/config.yaml'
|
| 19 |
+
hubert_gpu=False
|
| 20 |
+
svc_model = Svc(project_name,config_path,hubert_gpu, model_path)
|
| 21 |
+
print('model loaded')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|