forked from SeanNaren/deepspeech.pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sean Naren
authored
Feb 16, 2017
1 parent
ce07d8b
commit 906771b
Showing
11 changed files
with
302 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import data_loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
import argparse | ||
from __future__ import print_function | ||
|
||
import fnmatch | ||
import io | ||
import os | ||
|
||
import subprocess | ||
|
||
parser = argparse.ArgumentParser(description='Creates training and testing manifests') | ||
parser.add_argument('--root_path', default='an4_dataset', help='Path to the dataset') | ||
|
||
""" | ||
We need to add progress bars like will did in gen audio. Just copy that code. | ||
We also need a call (basically the same in the dataloader, a find that gives us the total number of wav files) | ||
""" | ||
def _update_progress(progress): | ||
print("\rProgress: [{0:50s}] {1:.1f}%".format('#' * int(progress * 50), | ||
progress * 100), end="") | ||
|
||
|
||
def create_manifest(data_path, tag, ordered=True): | ||
manifest_path = '%s_manifest.csv' % tag | ||
file_paths = [] | ||
with os.popen('find %s -type f -name "*.wav"' % data_path) as pipe: | ||
for file_path in pipe: | ||
file_paths.append(file_path.strip()) | ||
wav_files = [os.path.join(dirpath, f) | ||
for dirpath, dirnames, files in os.walk(data_path) | ||
for f in fnmatch.filter(files, '*.wav')] | ||
size = len(wav_files) | ||
counter = 0 | ||
for file_path in wav_files: | ||
file_paths.append(file_path.strip()) | ||
counter += 1 | ||
_update_progress(counter / float(size)) | ||
print('\n') | ||
if ordered: | ||
print("Sorting files by length...") | ||
|
||
def func(element): | ||
output = subprocess.check_output( | ||
['soxi -D %s' % element.strip()], | ||
shell=True | ||
) | ||
return float(output) | ||
|
||
file_paths.sort(key=func) | ||
_order_files(file_paths) | ||
counter = 0 | ||
with io.FileIO(manifest_path, "w") as file: | ||
for wav_path in file_paths: | ||
transcript_path = wav_path.replace('/wav/', '/txt/').replace('.wav', '.txt') | ||
sample = os.path.abspath(wav_path) + ',' + os.path.abspath(transcript_path) + '\n' | ||
file.write(sample) | ||
counter += 1 | ||
_update_progress(counter / float(size)) | ||
print('\n') | ||
|
||
|
||
def _order_files(file_paths): | ||
print("Sorting files by length...") | ||
|
||
def func(element): | ||
output = subprocess.check_output( | ||
['soxi -D %s' % element.strip()], | ||
shell=True | ||
) | ||
return float(output) | ||
|
||
file_paths.sort(key=func) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.