import tkinter as tk import tkinter.filedialog import tkinter.ttk as ttk import tkinter as tk from tkinter import ttk import wave from utils.hparams import hparams from preprocessing.data_gen_utils import get_pitch_parselmouth,get_pitch_crepe import numpy as np import IPython.display as ipd import utils import librosa import torchcrepe from infer import * import logging from infer_tools.infer_tool import * from tkinter import Label from time import sleep import os # Create the main window window = tk.Tk() # Set the window title and size window.title("Diff-SVC Rendering Tool") window.geometry("250x400") # console Textbox textbox = tk.Text(window) textbox.grid(row=4, column=0, padx=20, pady=20, sticky="nsew") loading_animation_label = Label(window) loading_animation_label.grid(row=5, column=0) # Set the column and row to stretch to fill the available space window.grid_columnconfigure(0, weight=1) window.grid_rowconfigure(4, weight=1) button1 = ttk.Button(window, text="Load Model") button1.grid(row=0, column=0, padx=20, pady=20) pb = ttk.Progressbar( window, orient='horizontal', mode='indeterminate', length=250 ) def start(): pb.grid(column=0, row=5, padx=0, pady=0) pb.start(10) def stop(): pb.stop() pb.grid_remove() def button1_clicked(): filepath1 = tkinter.filedialog.askopenfilename(title = "Select CKPT File", filetypes=[("Checkpoint files", "*.ckpt")]) if filepath1 == '': tkinter.messagebox.showerror("Error", "No CKPT file selected") return filepath2 = tkinter.filedialog.askopenfilename(title = "Select YAML File",filetypes=[("Yaml files", "*.yaml")]) if filepath2 == '': tkinter.messagebox.showerror("Error", "No YAML file selected") return model_path = filepath1 config_path = filepath2 logging.getLogger('numba').setLevel(logging.WARNING) start() # Show a dialog box to input text global project_name project_name = tkinter.simpledialog.askstring("Input", "Enter project name:", parent=window) if project_name == '': tkinter.messagebox.showerror("Error", "No Project Name") return # Use the input text and the value of hubert_gpu as arguments when creating an instance of the Svc class global svc_model hubert_gpu = False svc_model = Svc(project_name, config_path, hubert_gpu, model_path) textbox.insert('end', 'model loaded\n') stop() # Assign the callback function to the button's "command" attribute button1["command"] = button1_clicked button2 = ttk.Button(window, text="Start Rendering") button2.grid(row=1, column=0, padx=20, pady=20) # Define a callback function for the second button def button2_clicked(): # Open a file selection dialog for WAV files filepath = tkinter.filedialog.askopenfilename(filetypes=[("WAV files", "*.wav")]) # Show a dialog box to input the "key" value key = tkinter.simpledialog.askinteger("Input", "Enter key value:", parent=window) textbox.insert('end', 'Rendering Started, please wait...\n') start() wav_gen = tkinter.simpledialog.askstring("Input", "Enter the track name:", parent=window) if not wav_gen.endswith('.wav'): wav_gen += '.wav' wav_fn = filepath demoaudio, sr = librosa.load(wav_fn) pndm_speedup = 20 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, use_gt_mel=False, add_noise_step=500,project_name=project_name,out_path=wav_gen) time.sleep(2) textbox.insert('end', 'Rendering process done!\nPlaying Audio now...') os.startfile(wav_gen) stop() button2["command"] = button2_clicked #Checkbox hubert_gpu = tk.BooleanVar() checkbox = tk.Checkbutton(window, text="Use GPU", variable=hubert_gpu) checkbox.grid(row=3, column=0) # Start the event loop window.mainloop()