import torch import torchaudio import gradio as gr from scipy.io import wavfile from scipy.io.wavfile import write knn_vc = torch.hub.load('bshall/knn-vc', 'knn_vc', prematched=True, trust_repo=True, pretrained=True, device='cpu') def voice_change(audio_in, audio_ref): samplerate1, data1 = wavfile.read(audio_in) samplerate2, data2 = wavfile.read(audio_ref) write("./audio_in.wav", samplerate1, data1) write("./audio_ref.wav", samplerate2, data2) query_seq = knn_vc.get_features("./audio_in.wav") matching_set = knn_vc.get_matching_set(["./audio_ref.wav"]) out_wav = knn_vc.match(query_seq, matching_set, topk=4) torchaudio.save('output.wav', out_wav[None], 16000) return 'output.wav' app = gr.Blocks() with app: gr.Markdown("#