From 85de840d073533795d5b2f83bedd62acb5b6dc4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Hackathon=208th=20No.7=E3=80=91Python?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=80=82=E9=85=8D=203=20(#3969)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update setup.py * add optional * fit with praatio>=6.0.0 * Apply suggestions from code review * Apply suggestions from code review * Apply suggestions from code review --- examples/other/g2p/get_g2p_data.py | 2 +- paddlespeech/server/restful/request.py | 2 +- paddlespeech/server/restful/response.py | 3 ++- paddlespeech/t2s/exps/ernie_sat/align.py | 4 ++-- setup.py | 4 ++-- utils/gen_duration_from_textgrid.py | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/other/g2p/get_g2p_data.py b/examples/other/g2p/get_g2p_data.py index 8fa3e53cd..87e7b9fdc 100644 --- a/examples/other/g2p/get_g2p_data.py +++ b/examples/other/g2p/get_g2p_data.py @@ -32,7 +32,7 @@ def get_baker_data(root_dir): alignment_fp, includeEmptyIntervals=True) # only with baker's annotation utt_id = alignment.tierNameList[0].split(".")[0] - intervals = alignment.tierDict[alignment.tierNameList[0]].entryList + intervals = alignment.getTier(alignment.tierNameList[0]).entries phones = [] for interval in intervals: label = interval.label diff --git a/paddlespeech/server/restful/request.py b/paddlespeech/server/restful/request.py index b7a32481f..068694de3 100644 --- a/paddlespeech/server/restful/request.py +++ b/paddlespeech/server/restful/request.py @@ -65,7 +65,7 @@ class TTSRequest(BaseModel): speed: float = 1.0 volume: float = 1.0 sample_rate: int = 0 - save_path: str = None + save_path: Optional[str] = None #****************************************************************************************/ diff --git a/paddlespeech/server/restful/response.py b/paddlespeech/server/restful/response.py index 3d991de43..12b264c02 100644 --- a/paddlespeech/server/restful/response.py +++ b/paddlespeech/server/restful/response.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from typing import List +from typing import Optional from pydantic import BaseModel @@ -62,7 +63,7 @@ class TTSResult(BaseModel): volume: float = 1.0 sample_rate: int duration: float - save_path: str = None + save_path: Optional[str] = None audio: str diff --git a/paddlespeech/t2s/exps/ernie_sat/align.py b/paddlespeech/t2s/exps/ernie_sat/align.py index a802d0295..e7c8083a8 100755 --- a/paddlespeech/t2s/exps/ernie_sat/align.py +++ b/paddlespeech/t2s/exps/ernie_sat/align.py @@ -41,11 +41,11 @@ def _readtg(tg_path: str, lang: str='en', fs: int=24000, n_shift: int=300): ends = [] words = [] - for interval in alignment.tierDict['words'].entryList: + for interval in alignment.getTier('words').entries: word = interval.label if word: words.append(word) - for interval in alignment.tierDict['phones'].entryList: + for interval in alignment.getTier('phones').entries: phone = interval.label phones.append(phone) ends.append(interval.end) diff --git a/setup.py b/setup.py index fa53b5d7e..184205926 100644 --- a/setup.py +++ b/setup.py @@ -96,9 +96,9 @@ base = [ "paddleslim>=2.3.4", "ppdiffusers>=0.9.0", "paddlespeech_feat", - "praatio>=5.0.0, <=5.1.1", + "praatio>=6.0.0", "prettytable", - "pydantic>=1.10.14, <2.0", + "pydantic", "pypinyin<=0.44.0", "pypinyin-dict", "python-dateutil", diff --git a/utils/gen_duration_from_textgrid.py b/utils/gen_duration_from_textgrid.py index 9ee0c05cc..54427665a 100755 --- a/utils/gen_duration_from_textgrid.py +++ b/utils/gen_duration_from_textgrid.py @@ -26,7 +26,7 @@ def readtg(tg_path, sample_rate=24000, n_shift=300): alignment = textgrid.openTextgrid(tg_path, includeEmptyIntervals=True) phones = [] ends = [] - for interval in alignment.tierDict["phones"].entryList: + for interval in alignment.getTier("phones").entries: phone = interval.label phones.append(phone) ends.append(interval.end)