def parallel(f):
    if random.gauss(0.5, 0.14) > 0.6:
        s = random.sample(files, random.randint(2, 6))
        y = combine_speakers(s, len(s))[0]
    else:
        y = read_wav(f)[0]

    y = random_sampling(y, length=random.randint(2000, 300_000))
    y = y / (np.max(np.abs(y)) + 1e-9)

    seed = random.randint(0, 100_000_000)
    x = calc(y.copy(), seed)
    if random.gauss(0.5, 0.14) > 0.6:
        print('add small noise')
        n = combine_speakers(noises, random.randint(1, 20))[0]
        n = calc(n, seed, True)
        combined, noise = augmentation.add_noise(x,
                                                 n,
                                                 factor=random.uniform(
                                                     0.01, 0.1),
                                                 return_noise=True)
    else:
        x = x / (np.max(np.abs(x)) + 1e-9)
        combined = x
    print(combined.shape, y.shape)
    return combined, y
Beispiel #2
0
def signal_augmentation(wav):
    seed = random.randint(0, 100_000_000)
    wav = calc(wav, seed)
    if random.gauss(0.5, 0.14) > 0.6:
        n, _ = malaya_speech.load(random.choice(noises), sr = 16000)
        n = calc(n, seed, True)
        combined = augmentation.add_noise(
            wav, n, factor = random.uniform(0.05, 0.3)
        )
    else:
        combined = wav
    return combined.astype('float32')
Beispiel #3
0
def parallel(f):
    if random.random() > 0.7:
        s = random.sample(files, random.randint(2, 6))
        y = combine_speakers(s, len(s))[0]
    else:
        y = random_sampling(
            read_wav(f)[0], length = random.randint(20000, 120_000)
        )

    n = combine_speakers(noises, random.randint(1, 20))[0]
    seed = random.randint(0, 100_000_000)
    y = calc(y, seed)
    n = calc(n, seed, True)
    combined, noise = augmentation.add_noise(
        y, n, factor = random.uniform(0.1, 0.9), return_noise = True
    )
    return combined, y, noise
Beispiel #4
0
def parallel(f):
    y = random_sampling(read_wav(f)[0], length=length)
    seed = random.randint(0, 100_000_000)
    x = calc(y, seed)
    if random.gauss(0.5, 0.14) > 0.6:
        print('add small noise')
        n = combine_speakers(noises, random.randint(1, 20))[0]
        n = calc(n, seed, True)
        combined, noise = augmentation.add_noise(
            x,
            n,
            factor=random.uniform(0.01, 0.1),
            return_noise=True,
            rescale=False,
        )
    else:
        combined = x
    noise = combined - y
    return combined, y, noise