-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathdata.py
More file actions
24 lines (20 loc) · 662 Bytes
/
data.py
File metadata and controls
24 lines (20 loc) · 662 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding: utf-8 -*-
# !/usr/bin/env python
'''
By Dabi Ahn. andabi412@gmail.com.
https://www.github.com/andabi
'''
import random
from os import walk
from config import ModelConfig
from preprocess import get_random_wav
class Data:
def __init__(self, path):
self.path = path
def next_wavs(self, sec, size=1):
wavfiles = []
for (root, dirs, files) in walk(self.path):
wavfiles.extend(['{}/{}'.format(root, f) for f in files if f.endswith(".wav")])
wavfiles = random.sample(wavfiles, size)
mixed, src1, src2 = get_random_wav(wavfiles, sec, ModelConfig.SR)
return mixed, src1, src2, wavfiles