How to use the nnmnkwii.datasets.PaddedFileSourceDataset function in nnmnkwii

To help you get started, we’ve selected a few nnmnkwii examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github r9y9 / nnmnkwii / tests / test_pack_pad_sequence.py View on Github external
def _get_small_datasets(padded=False, duration=False):
    if duration:
        X, Y = example_file_data_sources_for_duration_model()
    else:
        X, Y = example_file_data_sources_for_acoustic_model()
    if padded:
        X = PaddedFileSourceDataset(X, padded_length=1000)
        Y = PaddedFileSourceDataset(Y, padded_length=1000)
    else:
        X = FileSourceDataset(X)
        Y = FileSourceDataset(Y)
    return X, Y
github r9y9 / nnmnkwii / tests / test_datasets.py View on Github external
def _get_small_datasets(padded=False, duration=False, padded_length=1000):
    if duration:
        X, Y = example_file_data_sources_for_duration_model()
    else:
        X, Y = example_file_data_sources_for_acoustic_model()
    if padded:
        X = PaddedFileSourceDataset(X, padded_length=padded_length)
        Y = PaddedFileSourceDataset(Y, padded_length=padded_length)
    else:
        X = FileSourceDataset(X)
        Y = FileSourceDataset(Y)
    return X, Y
github r9y9 / nnmnkwii / tests / test_datasets.py View on Github external
def _get_small_datasets(padded=False, duration=False, padded_length=1000):
    if duration:
        X, Y = example_file_data_sources_for_duration_model()
    else:
        X, Y = example_file_data_sources_for_acoustic_model()
    if padded:
        X = PaddedFileSourceDataset(X, padded_length=padded_length)
        Y = PaddedFileSourceDataset(Y, padded_length=padded_length)
    else:
        X = FileSourceDataset(X)
        Y = FileSourceDataset(Y)
    return X, Y
github r9y9 / nnmnkwii / tests / test_preprocessing.py View on Github external
X_std = np.sqrt(X_var)
    assert np.isfinite(X_mean).all()
    assert np.isfinite(X_var).all()
    assert X_mean.shape[-1] == D
    assert X_var.shape[-1] == D

    _, X_std_hat = P.meanstd(X)
    assert np.allclose(X_std, X_std_hat)

    x = X[0]
    x_scaled = P.scale(x, X_mean, X_std)
    assert np.isfinite(x_scaled).all()

    # For padded dataset
    _, X = example_file_data_sources_for_acoustic_model()
    X = PaddedFileSourceDataset(X, 1000)
    # Should get same results with padded features
    X_mean_hat, X_var_hat = P.meanvar(X, lengths)
    assert np.allclose(X_mean, X_mean_hat)
    assert np.allclose(X_var, X_var_hat)

    # Inverse transform
    x = X[0]
    x_hat = P.inv_scale(P.scale(x, X_mean, X_std), X_mean, X_std)
    assert np.allclose(x, x_hat, atol=1e-5)
github r9y9 / nnmnkwii / tests / test_pack_pad_sequence.py View on Github external
def _get_small_datasets(padded=False, duration=False):
    if duration:
        X, Y = example_file_data_sources_for_duration_model()
    else:
        X, Y = example_file_data_sources_for_acoustic_model()
    if padded:
        X = PaddedFileSourceDataset(X, padded_length=1000)
        Y = PaddedFileSourceDataset(Y, padded_length=1000)
    else:
        X = FileSourceDataset(X)
        Y = FileSourceDataset(Y)
    return X, Y
github r9y9 / nnmnkwii / tests / test_preprocessing.py View on Github external
    @raises(ValueError)
    def __test_raise2(x, X_min, X_max):
        P.inv_minmax_scale(x)

    __test_raise1(x, X_min, X_max)
    __test_raise2(x, X_min, X_max)

    # Explicit scale_ and min_
    min_, scale_ = P.minmax_scale_params(X_min, X_max, feature_range=(0, 0.99))
    x_scaled_hat = P.minmax_scale(x, min_=min_, scale_=scale_)
    assert np.allclose(x_scaled, x_scaled_hat)

    # For padded dataset
    X, _ = example_file_data_sources_for_acoustic_model()
    X = PaddedFileSourceDataset(X, 1000)
    # Should get same results with padded features
    X_min_hat, X_max_hat = P.minmax(X, lengths)
    assert np.allclose(X_min, X_min_hat)
    assert np.allclose(X_max, X_max_hat)

    # Inverse transform
    x = X[0]
    x_hat = P.inv_minmax_scale(P.minmax_scale(x, X_min, X_max), X_min, X_max)
    assert np.allclose(x, x_hat)

    x_hat = P.inv_minmax_scale(
        P.minmax_scale(x, scale_=scale_, min_=min_), scale_=scale_, min_=min_)
    assert np.allclose(x, x_hat)
github azraelkuan / voice-conversion / train_gmm.py View on Github external
else:
        spectrogram = pysptk.mc2sp(
            mc.astype(np.float64), alpha=config.alpha, fftlen=config.fftlen)
        waveform = pyworld.synthesize(
            f0, spectrogram, aperiodicity, fs, config.frame_period)

    return waveform


clb_source = MyFileDataSource(data_root=config.data_root,
                              speakers=["bdl"], max_files=config.max_files)
slt_source = MyFileDataSource(data_root=config.data_root,
                              speakers=["slt"], max_files=config.max_files)

X = PaddedFileSourceDataset(clb_source, 1200).asarray()
Y = PaddedFileSourceDataset(slt_source, 1200).asarray()

# Alignment
X_aligned, Y_aligned = DTWAligner(verbose=0, dist=melcd).transform((X, Y))

# Drop 1st (power) dim
X_aligned, Y_aligned = X_aligned[:, :, 1:], Y_aligned[:, :, 1:]

# apply MLPG
static_dim = X_aligned.shape[-1]
if config.use_delta:
    X_aligned = apply_each2d_trim(delta_features, X_aligned, config.windows)
    Y_aligned = apply_each2d_trim(delta_features, Y_aligned, config.windows)

XY = np.concatenate((X_aligned, Y_aligned), axis=-1).reshape(-1, X_aligned.shape[-1]*2)
# remove zero padding
XY = remove_zeros_frames(XY)
github azraelkuan / voice-conversion / train_gmm.py View on Github external
waveform = engine.synthesis(x, b)
    else:
        spectrogram = pysptk.mc2sp(
            mc.astype(np.float64), alpha=config.alpha, fftlen=config.fftlen)
        waveform = pyworld.synthesize(
            f0, spectrogram, aperiodicity, fs, config.frame_period)

    return waveform


clb_source = MyFileDataSource(data_root=config.data_root,
                              speakers=["bdl"], max_files=config.max_files)
slt_source = MyFileDataSource(data_root=config.data_root,
                              speakers=["slt"], max_files=config.max_files)

X = PaddedFileSourceDataset(clb_source, 1200).asarray()
Y = PaddedFileSourceDataset(slt_source, 1200).asarray()

# Alignment
X_aligned, Y_aligned = DTWAligner(verbose=0, dist=melcd).transform((X, Y))

# Drop 1st (power) dim
X_aligned, Y_aligned = X_aligned[:, :, 1:], Y_aligned[:, :, 1:]

# apply MLPG
static_dim = X_aligned.shape[-1]
if config.use_delta:
    X_aligned = apply_each2d_trim(delta_features, X_aligned, config.windows)
    Y_aligned = apply_each2d_trim(delta_features, Y_aligned, config.windows)

XY = np.concatenate((X_aligned, Y_aligned), axis=-1).reshape(-1, X_aligned.shape[-1]*2)
# remove zero padding