Exemple #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
Exemple #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]
Exemple #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]
Exemple #4
0
WGAN = load_model(Complex_Fully_Connected_WGAN, Choosed_WGAN, (6, ))
# %%
samples = sample_net(WGAN, 6)
# %%
draw_frequency_analysis(samples)
# %%
draw_frequency_analysis_lpf(samples)

# %%
lpf_compare(samples)
# %%

origin = get_random_example(6, 300)
originf = fft_data(origin)
yf, _ = lpf_dimension_reduction(originf, 5)
yf = pad_data_zeros(yf, 151)
y = ifft_data(yf)
# %%
draw_frequency_analysis(origin)
# %%
draw_frequency_analysis(y)
# %%
compare(origin, y)
# %%
originw, win = window(origin, 'hamming')
originfw = fft_data(originw)
yfw, _ = lpf_dimension_reduction(originfw, 5)
yfw = pad_data_zeros(yfw, 151)
yw = ifft_data(yfw)
yw = iwindow(yw, win, 0.7)
# %%