Exemplo n.º 1
0
def play_rnn_OLA(model, path, n, win, format='rov', args=None, translation=True, lpf=True):
    net = model(*args)
    net.load_state_dict(torch.load(path))

    x = net.generate(1, n).detach().squeeze().numpy()
    
    x = iflatten_complex_data_with(x, 31)
    x = pad_data_zeros(x, get_single_side_frequency().shape[0])
    x = ifft_data(x)
    x = iwindow(x, win + 0.001, 0.9)
    x = istandardize_data(x)

    x = overlap_and_add_data(x)
    if lpf:
        x = low_pass_filter(x)

    write_one_file('example', x, format=format)

    cmd = CMD + PAR1 + 'example' + PAR2
    if translation:
        cmd += TRANSLATION

    os.system(cmd)

    return x
Exemplo n.º 2
0
    def example(self):
        # Generate an example with numpy array data type
        x = self.generate(1).detach().cpu()
        x = np.array(x)
        x = iflatten_complex_data_with(x, 16)
        x = pad_data_zeros(x, get_single_side_frequency().shape[0])
        x = ifft_data(x)
        # x = iwindow(x, WIN, 0.8)

        return x[0]
Exemplo n.º 3
0
    def example(self, r):
        # Generate an example with numpy array data type
        global dim
        x = self.generate(1, r).detach().cpu()
        x = x.squeeze().unsqueeze(0)
        x = np.array(x)
        x = iflatten_complex_data_with(x, 31)
        x = pad_data_zeros(x, get_single_side_frequency().shape[0])
        x = ifft_data(x)
        # x = iwindow(x, WIN, 0.8)

        return x[0]