From 675cff258bd2fb0f4c1eaea175b93ae696313c17 Mon Sep 17 00:00:00 2001 From: TianYuan Date: Fri, 17 Dec 2021 16:13:19 +0800 Subject: [PATCH] [TTS]fix praatio version, test=tts (#1158) * fix praatio version, test=tts * fix praatio version, test=tts --- examples/other/g2p/get_g2p_data.py | 4 ++-- examples/other/g2p/path.sh | 10 ++++++++++ examples/other/tn/path.sh | 10 ++++++++++ .../exps/voice_cloning/tacotron2_ge2e/process_wav.py | 4 ++-- requirements.txt | 2 +- setup.py | 2 +- utils/gen_duration_from_textgrid.py | 4 ++-- 7 files changed, 28 insertions(+), 8 deletions(-) create mode 100755 examples/other/g2p/path.sh create mode 100755 examples/other/tn/path.sh diff --git a/examples/other/g2p/get_g2p_data.py b/examples/other/g2p/get_g2p_data.py index 61ef3d09..9b43ca62 100644 --- a/examples/other/g2p/get_g2p_data.py +++ b/examples/other/g2p/get_g2p_data.py @@ -15,7 +15,7 @@ import argparse from collections import defaultdict from pathlib import Path -from praatio import tgio +from praatio import textgrid def get_baker_data(root_dir): @@ -28,7 +28,7 @@ def get_baker_data(root_dir): alignment_files = [f for f in alignment_files if f.stem not in exclude] data_dict = defaultdict(dict) for alignment_fp in alignment_files: - alignment = tgio.openTextgrid(alignment_fp) + alignment = textgrid.openTextgrid(alignment_fp, includeEmptyIntervals=True) # only with baker's annotation utt_id = alignment.tierNameList[0].split(".")[0] intervals = alignment.tierDict[alignment.tierNameList[0]].entryList diff --git a/examples/other/g2p/path.sh b/examples/other/g2p/path.sh new file mode 100755 index 00000000..98fb9609 --- /dev/null +++ b/examples/other/g2p/path.sh @@ -0,0 +1,10 @@ +#!/bin/bash +export MAIN_ROOT=`realpath ${PWD}/../../../` + +export PATH=${MAIN_ROOT}:${MAIN_ROOT}/utils:${PATH} +export LC_ALL=C + +export PYTHONDONTWRITEBYTECODE=1 +# Use UTF-8 in Python to avoid UnicodeDecodeError when LC_ALL=C +export PYTHONIOENCODING=UTF-8 +export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} diff --git a/examples/other/tn/path.sh b/examples/other/tn/path.sh new file mode 100755 index 00000000..98fb9609 --- /dev/null +++ b/examples/other/tn/path.sh @@ -0,0 +1,10 @@ +#!/bin/bash +export MAIN_ROOT=`realpath ${PWD}/../../../` + +export PATH=${MAIN_ROOT}:${MAIN_ROOT}/utils:${PATH} +export LC_ALL=C + +export PYTHONDONTWRITEBYTECODE=1 +# Use UTF-8 in Python to avoid UnicodeDecodeError when LC_ALL=C +export PYTHONIOENCODING=UTF-8 +export PYTHONPATH=${MAIN_ROOT}:${PYTHONPATH} diff --git a/paddlespeech/t2s/exps/voice_cloning/tacotron2_ge2e/process_wav.py b/paddlespeech/t2s/exps/voice_cloning/tacotron2_ge2e/process_wav.py index c1be0a37..56d8e4c3 100644 --- a/paddlespeech/t2s/exps/voice_cloning/tacotron2_ge2e/process_wav.py +++ b/paddlespeech/t2s/exps/voice_cloning/tacotron2_ge2e/process_wav.py @@ -19,12 +19,12 @@ from pathlib import Path import librosa import numpy as np import soundfile as sf -from praatio import tgio +from praatio import textgrid from tqdm import tqdm def get_valid_part(fpath): - f = tgio.openTextgrid(fpath) + f = textgrid.openTextgrid(fpath, includeEmptyIntervals=True) start = 0 phone_entry_list = f.tierDict['phones'].entryList diff --git a/requirements.txt b/requirements.txt index 3708bb06..42cb33f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,7 @@ paddlespeech_feat pandas phkit Pillow -praatio~=4.1 +praatio==5.0.0 pre-commit pybind11 pypi-kenlm diff --git a/setup.py b/setup.py index a5b773ed..9d680ea8 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ requirements = { "pandas", "paddleaudio", "paddlespeech_feat", - "praatio~=4.1", + "praatio==5.0.0", "pypinyin", "python-dateutil", "pyworld", diff --git a/utils/gen_duration_from_textgrid.py b/utils/gen_duration_from_textgrid.py index b2a5fa3d..9ee0c05c 100755 --- a/utils/gen_duration_from_textgrid.py +++ b/utils/gen_duration_from_textgrid.py @@ -18,12 +18,12 @@ from pathlib import Path import librosa import numpy as np import yaml -from praatio import tgio +from praatio import textgrid from yacs.config import CfgNode def readtg(tg_path, sample_rate=24000, n_shift=300): - alignment = tgio.openTextgrid(tg_path, readRaw=True) + alignment = textgrid.openTextgrid(tg_path, includeEmptyIntervals=True) phones = [] ends = [] for interval in alignment.tierDict["phones"].entryList: