# Importing libraries import gradio as gr from asteroid.models import ConvTasNet, DPRNNTasNet import torch import os import shutil # ------------------ # class tester(): def __init__(self, model): # Modeling self.model = model # Test Directory will also contain output after files self.test_dir = 'asset/test_subject/' def prepare_test(self): # Removing older test and their results if os.path.exists(self.test_dir): shutil.rmtree(self.test_dir) if not os.path.exists(self.test_dir): os.mkdir(self.test_dir) def test(self, path): self.prepare_test() test_subject = self.test_dir + 'test.wav' shutil.copyfile(path, test_subject) self.model.separate(test_subject,force_overwrite=True, resample=True) def load_model(): model = torch.load('asset/model/model_three.bin') return model def separator(original_audio, path): Test = tester(load_model()) Test.prepare_test() Test.test(path) separated_audios = list() separated_audios.append('asset/test_subject/test.wav') separated_audios.append('asset/test_subject/test_est1.wav') separated_audios.append('asset/test_subject/test_est2.wav') separated_audios.append('asset/test_subject/test_est3.wav') return separated_audios demo = gr.Blocks(theme=gr.themes.Soft()) with demo: gr.Markdown('''
It is a shareable demonstration window which can be used to view result on any device by setting 'share' a launch parameter 'True'. It displays original audio for mixture of speaker, seperated audio by our model and original individual speaker audio.