在pycharm上执行这段代码时,我得到了以下错误:
TypeError: get_tier_by_name() takes exactly 2 arguments (3 given)以下是代码
import os
import tgt
from pydub import AudioSegment
tg = tgt.read_textgrid("arabic1_0.TextGrid")
ipu_tier = tg.get_tier_by_name(0,60)
xmin = ipu_tier[1]._start_time
xmax = ipu_tier[1]._end_time
audio = AudioSegment.from_wav("arabic1.wav")
goal_split_wav = audio[xmin * 1000:xmax * 1000]
goal_split_wav.export("output_path") # the path of the splited wav发布于 2018-10-08 19:50:42
您正在传递2个参数,它需要1个:
在tgt/core.py中:
def get_tier_by_name(self, name):
'''Get the first tier with the specified name.'''
for tier in self._tiers:
if tier.name == name:
return tier
raise ValueError('Textgrid ' + self.filename +
' does not have a tier called "' + name + '".')您正在传递2个数字,您应该向它传递一个带有层名称的字符串
您可以使用get_tier_names检查层名称
names = tg.get_tier_names()https://stackoverflow.com/questions/52701522
复制相似问题