Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--alphabet-format flag #1874

Merged
merged 2 commits into from
Feb 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions util/check_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,30 @@

'''
Usage: $ python3 check_characters.py "INFILE"
e.g. $ python3 ../DeepSpeech/util/check_characters.py "/home/data/*.csv"
e.g. $ python3 ../DeepSpeech/util/check_characters.py "/home/data/french.csv"
e.g. $ python3 ../DeepSpeech/util/check_characters.py "train.csv test.csv"
e.g. $ python3 check_characters.py -csv /home/data/french.csv
e.g. $ python3 check_characters.py -csv ../train.csv,../test.csv
e.g. $ python3 check_characters.py -alpha -csv ../train.csv

Point this script to your transcripts, and it returns
to the terminal the unique set of characters in those
files (combined).

These files are assumed to be comma delimited,
with the transcript being the third field.
These files are assumed to be csv, with the transcript being the third field.

The script simply reads all the text from all the files,
storing a set of unique characters that were seen
along the way.
'''
import argparse
import os

inFiles=sys.argv[1]
if "*" in inFiles:
inFiles = glob.glob(inFiles)
else:
inFiles = inFiles.split()
parser = argparse.ArgumentParser()

parser.add_argument('-csv', '--csv-files', help='Str. Filenames as a comma separated list', required=True)
parser.add_argument("-alpha", "--alphabet-format",help="Bool. Print in format for alphabet.txt",action='store_true')
JRMeyer marked this conversation as resolved.
Show resolved Hide resolved
parser.set_defaults(alphabet_format=False)
args = parser.parse_args()
inFiles = [os.path.abspath(i) for i in args.csv_files.split(',')]

print("### Reading in the following transcript files: ###")
print(inFiles)
Expand All @@ -43,5 +46,9 @@
csvFile.close()

print("### The following unique characters were found in your transcripts: ###")
print(list(allText))
print("### All these characters should be in your data/alphabet.txt file ###")
if args.alphabet_format:
for char in list(allText):
print(char)
print("### ^^^ You can copy-paste these into data/alphabet.txt ###")
else:
print(list(allText))