【Hackathon 8th No.7】Python版本适配 3 (#3969)

* 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
pull/3998/head
张春乔 8 months ago committed by GitHub
parent 65dbf46cdb
commit 85de840d07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -32,7 +32,7 @@ def get_baker_data(root_dir):
alignment_fp, includeEmptyIntervals=True) alignment_fp, includeEmptyIntervals=True)
# only with baker's annotation # only with baker's annotation
utt_id = alignment.tierNameList[0].split(".")[0] utt_id = alignment.tierNameList[0].split(".")[0]
intervals = alignment.tierDict[alignment.tierNameList[0]].entryList intervals = alignment.getTier(alignment.tierNameList[0]).entries
phones = [] phones = []
for interval in intervals: for interval in intervals:
label = interval.label label = interval.label

@ -65,7 +65,7 @@ class TTSRequest(BaseModel):
speed: float = 1.0 speed: float = 1.0
volume: float = 1.0 volume: float = 1.0
sample_rate: int = 0 sample_rate: int = 0
save_path: str = None save_path: Optional[str] = None
#****************************************************************************************/ #****************************************************************************************/

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import List from typing import List
from typing import Optional
from pydantic import BaseModel from pydantic import BaseModel
@ -62,7 +63,7 @@ class TTSResult(BaseModel):
volume: float = 1.0 volume: float = 1.0
sample_rate: int sample_rate: int
duration: float duration: float
save_path: str = None save_path: Optional[str] = None
audio: str audio: str

@ -41,11 +41,11 @@ def _readtg(tg_path: str, lang: str='en', fs: int=24000, n_shift: int=300):
ends = [] ends = []
words = [] words = []
for interval in alignment.tierDict['words'].entryList: for interval in alignment.getTier('words').entries:
word = interval.label word = interval.label
if word: if word:
words.append(word) words.append(word)
for interval in alignment.tierDict['phones'].entryList: for interval in alignment.getTier('phones').entries:
phone = interval.label phone = interval.label
phones.append(phone) phones.append(phone)
ends.append(interval.end) ends.append(interval.end)

@ -96,9 +96,9 @@ base = [
"paddleslim>=2.3.4", "paddleslim>=2.3.4",
"ppdiffusers>=0.9.0", "ppdiffusers>=0.9.0",
"paddlespeech_feat", "paddlespeech_feat",
"praatio>=5.0.0, <=5.1.1", "praatio>=6.0.0",
"prettytable", "prettytable",
"pydantic>=1.10.14, <2.0", "pydantic",
"pypinyin<=0.44.0", "pypinyin<=0.44.0",
"pypinyin-dict", "pypinyin-dict",
"python-dateutil", "python-dateutil",

@ -26,7 +26,7 @@ def readtg(tg_path, sample_rate=24000, n_shift=300):
alignment = textgrid.openTextgrid(tg_path, includeEmptyIntervals=True) alignment = textgrid.openTextgrid(tg_path, includeEmptyIntervals=True)
phones = [] phones = []
ends = [] ends = []
for interval in alignment.tierDict["phones"].entryList: for interval in alignment.getTier("phones").entries:
phone = interval.label phone = interval.label
phones.append(phone) phones.append(phone)
ends.append(interval.end) ends.append(interval.end)

Loading…
Cancel
Save