Revert "Merge pull request #3424 from mozilla/io-fixes"

This reverts commit ab1288ffde, reversing
changes made to 08d18d7328.
This commit is contained in:
Reuben Morais 2020-11-19 16:58:01 +02:00
Родитель ee68367580
Коммит f5cbda694a
6 изменённых файлов: 12 добавлений и 19 удалений

Просмотреть файл

@ -1,2 +0,0 @@
tensorflow/
data/

Просмотреть файл

@ -15,8 +15,8 @@ def fail(message):
def compare_samples():
sample1 = load_sample(CLI_ARGS.sample1).unpack()
sample2 = load_sample(CLI_ARGS.sample2).unpack()
sample1 = load_sample(CLI_ARGS.sample1)
sample2 = load_sample(CLI_ARGS.sample2)
if sample1.audio_format != sample2.audio_format:
fail('Samples differ on: audio-format ({} and {})'.format(sample1.audio_format, sample2.audio_format))
if sample1.duration != sample2.duration:

Просмотреть файл

@ -811,7 +811,7 @@ def export():
load_graph_for_evaluation(session)
output_filename = FLAGS.export_file_name + '.pb'
if FLAGS.remove_export:
if FLAGS.remove_remote_export:
if isdir_remote(FLAGS.export_dir):
log_info('Removing old export')
remove_remote(FLAGS.export_dir)

Просмотреть файл

@ -118,19 +118,15 @@ class Sample:
self.audio_type = new_audio_type
def _unpack_and_change_audio_type(sample_and_audio_type):
packed_sample, audio_type, bitrate = sample_and_audio_type
if hasattr(sample, 'unpack'):
sample = packed_sample.unpack()
else:
sample = packed_sample
def _change_audio_type(sample_and_audio_type):
sample, audio_type, bitrate = sample_and_audio_type
sample.change_audio_type(audio_type, bitrate=bitrate)
return sample
def change_audio_types(packed_samples, audio_type=AUDIO_TYPE_PCM, bitrate=None, processes=None, process_ahead=None):
def change_audio_types(samples, audio_type=AUDIO_TYPE_PCM, bitrate=None, processes=None, process_ahead=None):
with LimitingPool(processes=processes, process_ahead=process_ahead) as pool:
yield from pool.imap(_unpack_and_change_audio_type, map(lambda s: (s, audio_type, bitrate), packed_samples))
yield from pool.imap(_change_audio_type, map(lambda s: (s, audio_type, bitrate), samples))
def get_audio_type_from_extension(ext):

Просмотреть файл

@ -152,10 +152,7 @@ def _init_augmentation_worker(preparation_context):
def _load_and_augment_sample(timed_sample, context=None):
sample, clock = timed_sample
if hasattr(sample, 'unpack'):
realized_sample = sample.unpack()
else:
realized_sample = sample
realized_sample = sample.unpack()
return _augment_sample((realized_sample, clock), context)

Просмотреть файл

@ -14,6 +14,8 @@ import sys
from pkg_resources import parse_version
from .io import isdir_remote, open_remote, is_remote_path
DEFAULT_SCHEMES = {
'deepspeech': 'https://community-tc.services.mozilla.com/api/index/v1/task/project.deepspeech.deepspeech.native_client.%(branch_name)s.%(arch_string)s/artifacts/public/%(artifact_name)s',
'tensorflow': 'https://community-tc.services.mozilla.com/api/index/v1/task/project.deepspeech.tensorflow.pip.%(branch_name)s.%(arch_string)s/artifacts/public/%(artifact_name)s'
@ -41,7 +43,7 @@ def maybe_download_tc(target_dir, tc_url, progress=True):
assert target_dir is not None
if not os.path.isdir(target_dir):
if not is_remote_path(target_dir):
try:
os.makedirs(target_dir)
except OSError as e:
@ -60,7 +62,7 @@ def maybe_download_tc(target_dir, tc_url, progress=True):
print('File already exists: %s' % target_file)
if is_gzip:
with open(target_file, "r+b") as frw:
with open_remote(target_file, "r+b") as frw:
decompressed = gzip.decompress(frw.read())
frw.seek(0)
frw.write(decompressed)