作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个由Prosodylab-Aligner生成的textGrid文件,可以在Praat
中打开它。是否有可能摆脱这样的文本文件:
Word in text | Pronounciation started at
Hello 0:0:0.000
my 0:0:1.125
friends 0:0:2.750
File type = "ooTextFile"
Object class = "TextGrid"
xmin = 0.0
xmax = 2.53
tiers? <exists>
size = 2
item []:
item [1]:
class = "IntervalTier"
name = "phones"
xmin = 0.0
xmax = 2.53
intervals: size = 13
intervals [1]:
xmin = 0.0
xmax = 0.62
text = "sil"
intervals [2]:
xmin = 0.62
xmax = 0.78
text = "K"
intervals [3]:
xmin = 0.78
xmax = 0.81
text = "L"
intervals [4]:
xmin = 0.81
xmax = 0.92
text = "IH1"
intervals [5]:
xmin = 0.92
xmax = 1.02
text = "K"
intervals [6]:
xmin = 1.02
xmax = 1.07
text = ""
intervals [7]:
xmin = 1.07
xmax = 1.22
text = "T"
intervals [8]:
xmin = 1.22
xmax = 1.31
text = "UW1"
intervals [9]:
xmin = 1.31
xmax = 1.51
text = "S"
intervals [10]:
xmin = 1.51
xmax = 1.67
text = "T"
intervals [11]:
xmin = 1.67
xmax = 1.85
text = "AA1"
intervals [12]:
xmin = 1.85
xmax = 1.88
text = "P"
intervals [13]:
xmin = 1.88
xmax = 2.53
text = "sil"
item [2]:
class = "IntervalTier"
name = "words"
xmin = 0.0
xmax = 2.53
intervals: size = 6
intervals [1]:
xmin = 0.0
xmax = 0.62
text = "sil"
intervals [2]:
xmin = 0.62
xmax = 1.02
text = "CLICK"
intervals [3]:
xmin = 1.02
xmax = 1.07
text = "sp"
intervals [4]:
xmin = 1.07
xmax = 1.31
text = "TO"
intervals [5]:
xmin = 1.31
xmax = 1.88
text = "STOP"
intervals [6]:
xmin = 1.88
xmax = 2.53
text = "sil"
最佳答案
由于这是一个Praat
文件,并且您说可以在Praat
中打开它,所以我认为一个更好的解决方案是使用Praat
来解决它。如下所示的脚本涉及更少的信念飞跃:
form Parse TextGrid...
sentence File /path/to/your.TextGrid
integer Tier 2
endform
Read from file: file$
intervals = Get number of intervals: tier
writeInfoLine: "Word in text", tab$, "Pronounciation started at"
for i to intervals
label$ = Get label of interval: tier, i
if label$ != ""
start = Get start point: tier, i
appendInfoLine: label$, tab$, string$(start)
endif
endfor
Praat
一样调用
praat /path/to/your/script.praat "/path/to/your.TextGrid" 2
,并从
stdout
获得所需的输出。
关于audio - 使用Praat或任何其他音频处理工具从textGrid创建文本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24493126/
TextGrid 是 Praat 程序使用的“分割”文件。我想编写一个解析器来验证数据。我的问题是: 您将如何为这种格式编写解析器?逐行阅读还是其他?这是已知格式吗? File type = "ooT
我是一名优秀的程序员,十分优秀!