textgrid-python模块基础使用
- import textgrid
-
- # 读取音频文件给定最大时长
- tg=textgrid.TextGrid(minTime=0,maxTime=2)
- print(tg.__dict__)
-
- tier_word=textgrid.PointTier(name="word", minTime=0., maxTime=2) # 添加一层,命名为word层
- tier_phone=textgrid.PointTier(name="word", minTime=0., maxTime=2) # 添加一层,命名为phone音素层
-
- # 添加分割线
- point=textgrid.Point(time=0.1,mark="s")
- tier_word.addPoint(point)
- tier_phone.addPoint(point)
-
- # 添加到tg对象中
- tg.tiers.append(tier_word)
- tg.tiers.append(tier_phone)
-
- print(tg.__dict__)
- # 写入保存
- tg.write("1.interval")