|
|
@ -85,9 +85,9 @@ class DataGenerator(object):
|
|
|
|
self._rng = random.Random(random_seed)
|
|
|
|
self._rng = random.Random(random_seed)
|
|
|
|
self._epoch = 0
|
|
|
|
self._epoch = 0
|
|
|
|
# for caching tar files info
|
|
|
|
# for caching tar files info
|
|
|
|
self.local_data = local()
|
|
|
|
self._local_data = local()
|
|
|
|
self.local_data.tar2info = {}
|
|
|
|
self._local_data.tar2info = {}
|
|
|
|
self.local_data.tar2object = {}
|
|
|
|
self._local_data.tar2object = {}
|
|
|
|
|
|
|
|
|
|
|
|
def process_utterance(self, filename, transcript):
|
|
|
|
def process_utterance(self, filename, transcript):
|
|
|
|
"""Load, augment, featurize and normalize for speech data.
|
|
|
|
"""Load, augment, featurize and normalize for speech data.
|
|
|
@ -240,16 +240,16 @@ class DataGenerator(object):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
if file.startswith('tar:'):
|
|
|
|
if file.startswith('tar:'):
|
|
|
|
tarpath, filename = file.split(':', 1)[1].split('#', 1)
|
|
|
|
tarpath, filename = file.split(':', 1)[1].split('#', 1)
|
|
|
|
if 'tar2info' not in self.local_data.__dict__:
|
|
|
|
if 'tar2info' not in self._local_data.__dict__:
|
|
|
|
self.local_data.tar2info = {}
|
|
|
|
self._local_data.tar2info = {}
|
|
|
|
if 'tar2object' not in self.local_data.__dict__:
|
|
|
|
if 'tar2object' not in self._local_data.__dict__:
|
|
|
|
self.local_data.tar2object = {}
|
|
|
|
self._local_data.tar2object = {}
|
|
|
|
if tarpath not in self.local_data.tar2info:
|
|
|
|
if tarpath not in self._local_data.tar2info:
|
|
|
|
object, infoes = self._parse_tar(tarpath)
|
|
|
|
object, infoes = self._parse_tar(tarpath)
|
|
|
|
self.local_data.tar2info[tarpath] = infoes
|
|
|
|
self._local_data.tar2info[tarpath] = infoes
|
|
|
|
self.local_data.tar2object[tarpath] = object
|
|
|
|
self._local_data.tar2object[tarpath] = object
|
|
|
|
return self.local_data.tar2object[tarpath].extractfile(
|
|
|
|
return self._local_data.tar2object[tarpath].extractfile(
|
|
|
|
self.local_data.tar2info[tarpath][filename])
|
|
|
|
self._local_data.tar2info[tarpath][filename])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return open(file, 'r')
|
|
|
|
return open(file, 'r')
|
|
|
|
|
|
|
|
|
|
|
|