Beispiel #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
Beispiel #2
0
def play_one_video_from(model, path, format='rov', args=None, translation=True):
    net = model(*args)

    net.load_state_dict(torch.load(path))
    
    example = [net.example()]
    example = istandardize_data(example)[0]

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

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

    os.system(cmd)

    return net
Beispiel #3
0
def play_real(length, translation=True):
    data = standardize_all_data()
    data = trim_data(data, length)
    data = istandardize_data(data)
    x = random.choice(data)
    print(type(x))
    print(x.shape)
    x = np.array(x)

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

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

    os.system(cmd)

    return x
Beispiel #4
0
def play_long_video_from(model, path, length, format='rov', args=None, translation=True, lpf=True):
    net = model(*args)
    net.load_state_dict(torch.load(path))

    y = get_real_example(net)
    while y.shape[0] < length:
        y = overlap_and_add(y, get_real_example(net))

    if lpf:
        y = low_pass_filter(y)

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

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

    os.system(cmd)

    return y
Beispiel #5
0
def play_long_video_istft(model, path, n, win, format='rov', args=None, translation=True, lpf=True):
    net = model(*args)
    net.load_state_dict(torch.load(path))

    data = []
    for i in range(n):
        data.append(net.example()[0])

    print('data ' + str(len(data)))

    result = griffin(data, win)
    result = istandardize_data([result])[0]
    if lpf:
        result = low_pass_filter(result)

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

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

    os.system(cmd)

    return result
print(config.FORMAT_HEADER)
# %%
print(config.HEADERS[config.DATA_FORMAT])
# %%
get_trajectory(format='qtn')
# %%
from data_reader import get_trajectory
from data_reader import write_one_file
import os
import numpy as np
import config
# %%
data = get_trajectory()
x = data[3]
path = os.path.join(config.DATA_PATH, 'Generated', 'example.rov')
write_one_file(path, x, 'rov')
# %%
np.zeros()

# %%
import numpy as np
import matplotlib.pyplot as plt

# %%
x = np.linspace(0, 100, 400)
y1 = x * 3 - 300
y2 = x * (-3) + 200
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 5))
ax1.plot(x, y1, label='legend')
ax1.plot(x, y2, label='haha')
ax1.legend()