Esempio n. 1
0
                        os.path.join(wavs_path, fn + ".wav"), wav, hp.sr)

                chapter += 1
            except FileNotFoundError:
                break

    _convert_mp3_to_wav('01_Genesis', 1)
    _convert_mp3_to_wav('02_Exodus', 2)
    _convert_mp3_to_wav('03_Leviticus', 3)
    metadata_csv.close()
    print("total audio duration: %ss" %
          (time.strftime('%H:%M:%S', time.gmtime(total_duration_s))))

    # pre process
    print("pre processing...")
    mb_speech = MBSpeech([])
    preprocess(dataset_path, mb_speech)
else:
    if not args.dataset:
        print("You must specify a dataset")
        sys.exit(0)

    dataset_name = args.dataset
    datasets_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                 'datasets')
    dataset_path = os.path.join(datasets_path, dataset_name)
    if not os.path.isdir(dataset_path):
        print("%s does not exist" % dataset_path)
        print("You should put your unprocessed dataset inside %s" %
              datasets_path)
        sys.exit(0)
import argparse
from tqdm import *
import numpy as np

from torch.utils.data import ConcatDataset
from datasets import Compose, LoadAudio, ComputeMagSpectrogram

parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("--dataset",
                    choices=['librispeech', 'mbspeech', 'bolorspeech', 'backgroundsounds'],
                    default='bolorspeech', help='dataset name')
args = parser.parse_args()

if args.dataset == 'mbspeech':
    from datasets.mb_speech import MBSpeech
    dataset = MBSpeech()
elif args.dataset == 'librispeech':
    from datasets.libri_speech import LibriSpeech
    dataset = ConcatDataset([
        LibriSpeech(name='train-clean-100'),
        LibriSpeech(name='train-clean-360'),
        LibriSpeech(name='train-other-500'),
        LibriSpeech(name='dev-clean',)
    ])
elif args.dataset == 'backgroundsounds':
    from datasets.background_sounds import BackgroundSounds
    dataset = BackgroundSounds(is_random=False)
elif args.dataset == 'bolorspeech':
    from datasets.bolor_speech import BolorSpeech
    dataset = ConcatDataset([
        BolorSpeech(name='train'),