Skip to content

Commit

Permalink
fixed flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
kan-bayashi authored and G-Thor committed Apr 28, 2022
1 parent 10e6c7e commit 664414c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions egs2/TEMPLATE/asr1/pyscripts/utils/convert_text_to_phn.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env python3

# Copyright 2021 Tomoki Hayashi
# Copyright 2021 Tomoki Hayashi and Gunnar Thor
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)

"""Convert kaldi-style text into phonemized sentences."""

import argparse
import codecs
from tqdm import tqdm
import contextlib

from joblib import delayed
from joblib import Parallel, parallel
from joblib import Parallel
from joblib import parallel
from tqdm import tqdm

from espnet2.text.cleaner import TextCleaner
from espnet2.text.phoneme_tokenizer import PhonemeTokenizer
Expand All @@ -36,9 +37,7 @@ def main():
text = {line.split()[0]: " ".join(line.split()[1:]) for line in lines}
if cleaner is not None:
text = {k: cleaner(v) for k, v in text.items()}
with tqdm_joblib(
tqdm(total=len(text.values()), desc="Phonemizing")
) as progress_bar:
with tqdm_joblib(tqdm(total=len(text.values()), desc="Phonemizing")):
phns_list = Parallel(n_jobs=args.nj)(
[
delayed(phoneme_tokenizer.text2tokens)(sentence)
Expand All @@ -52,9 +51,11 @@ def main():

@contextlib.contextmanager
def tqdm_joblib(tqdm_object):
"""
Context manager to patch joblib to report
into tqdm progress bar given as argument
"""Patch joblib to report into tqdm progress bar given as argument.
Reference:
https://stackoverflow.com/questions/24983493
"""

class TqdmBatchCompletionCallback(parallel.BatchCompletionCallBack):
Expand Down

0 comments on commit 664414c

Please sign in to comment.