Comments (1)
For another dataset
import torch
import os, sys
import audio_torch as audio
import random
import numpy as np
import hparams as hp
import glob
from tqdm import tqdm
from functools import partial
from multiprocessing import cpu_count
from concurrent.futures import ProcessPoolExecutor
import warnings
warnings.filterwarnings('ignore')
DATASET = "aishell3" # aishell3 or biaobei
def _process_utterance(in_path, out_path, index):
wav = torch.Tensor(audio.load_wav(in_path)) #, hp.sample_rate, encode=False))
noi = audio.add_noise(wav, quantization_channel=hp.quantization_channel)
mix = wav.float() + noi
wav_name = f"{index}.wav.npy"
noi_name = f"{index}.noi.npy"
mix_name = f"{index}.mix.npy"
if wav.size(0) > 44100:
np.save(os.path.join(out_path, wav_name), wav.numpy(), allow_pickle=False)
np.save(os.path.join(out_path, noi_name), noi.numpy(), allow_pickle=False)
np.save(os.path.join(out_path, mix_name), mix.numpy(), allow_pickle=False)
if __name__ == "__main__":
if len(sys.argv) == 1:
wav_path = "data_wav_path"
else:
wav_path = sys.argv[1]
max_workers = int(cpu_count()/4)+1
print(max_workers)
executor = ProcessPoolExecutor(max_workers=max_workers)
futures = []
os.makedirs(hp.dataset_path, exist_ok=True)
paths = glob.glob(wav_path+"/*")
length = len(paths)
for i in tqdm(range(length)):
path = paths[i]
index = path.split("/")[-1]
futures.append(executor.submit(partial(_process_utterance, os.path.join(path), hp.dataset_path, index)))
[future.result() for future in tqdm(futures)]
with open("dataset.txt", "w+", encoding="utf-8") as f:
for filename in glob.glob("dataset/*.wav.mix.npy"):
f.write(wav_path + "/"+ filename.split("/")[-1].replace(".mix.npy","")+"\n")
python preprocess.py <wav_path>
from convtasnet4basismelgan.
Related Issues (3)
- paper link HOT 1
- 22050Hz Tasnet Pretrain HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from convtasnet4basismelgan.