前不久,写了一个程序用Praat提取音强数据(按百分比),此程序是要进到音频的图形界面选中一段音频后才能提取相应的数据。当然,这样手工操作会取到你想要的音频数据,但是,对于大量的音频数据分析来说,这工作量是非常巨大的,所以我就在想有没有自动提取数据的办法?Praat是可以编程的,只要提供有足够的接口或方法,应该是没问题的,但是……这Praat是英文的,我的英文水平却是麻麻地
,看不懂……但是对于Programer的我们来说,不要求全部看明白,只要认得其中的一两个单词,知道大概意思就OK了
。经过不久的奋斗(虽然说是不久,但也废尽脑细胞啊……),程序终于出来了。看看下面:
#程序编写:何京宗 http://www.hejingzong.cn
#编写日期:2014-04-04
#程序功能:自动分段提取十点基频数据
#如有拷贝进行使用请保留版权声明,尊重作者劳动成果,谢谢。
form 请输入
comment 当前音频长度:
positive audioLength 6.0
endform
empty$=""
echo 'empty$'
Show all
Move cursor to... 0
Select later
Select earlier
#Select... 0 0.6
#Zoom to selection
beginTime=0.01
#Get begin of selection
pitch=Get pitch
n=0
perLength$=""
while beginTime+0.05<audioLength and n<30
while pitch=undefined and beginTime<audioLength
beginTime=beginTime+0.01
Move cursor to... 'beginTime'
#Select later
#Select earlier
pitch=Get pitch
endwhile
endTime=beginTime+0.01
pitch=Get pitch
while pitch!=undefined and endTime<audioLength
endTime=endTime+0.01
Move cursor to... 'endTime'
#Select later
#Select earlier
pitch=Get pitch
endwhile
endTime=endTime-0.01
if endTime>beginTime
Select... 'beginTime' 'endTime'
nn=n+1
c=endTime-beginTime
print 'nn':'beginTime:3' To 'endTime:3' Length:'c:3'
perLength$=perLength$+fixed$('c'*1000,0)+" "
print 'newline$'
#Zoom to selection
for i from 0 to 9
currentTime=beginTime+((endTime-beginTime)/9)*i
Move cursor to... 'currentTime'
pitch = Get pitch
print 'pitch:0'
if i < 9
printtab
endif
endfor
print 'newline$'
print 'newline$'
beginTime=endTime+0.02
Move cursor to... 'beginTime'
pitch=Get pitch
endif
n=n+1
endwhile
print 'newline$'
print 各段的时长如下(单位:ms):
print 'newline$'
print 'perLength$'此程序一出,哇塞,全部数据一点即出,太爽了。但是……但是现在提取的数据是精确到0.1秒的,运行起来没什么压力,如果要精确到0.001秒,也就是1毫秒,这程序运行起来就不爽了,6秒钟的音频要提取数据程序要运行150秒左右……虽然时间有点久,但是比起手动的来还是方便很多的。
(注:在Praat的频谱界面运行此程序默认只能精确到0.01)
需要精确到三位小数以上的请点击这里
特别说明:该脚本精确度有限,如需要更高精确度请下载使用最新的Praat汉化版VIP功能。
用法?用法跟前面那篇文章里说的差不多,只不过不用选择某一段音频而已
如您觉得本文对您有帮助,可以赞助博主一杯奶茶吗


