Praat根据标注出来的CV标记计算节奏参数

目前有关于二语学习领域节奏计算的研究很多,相关文献可以通过查找PVI节奏参数获得,这种方式首先要在Praat里标出一层,只有CV标记,分别代表元音之间的时间间隔和元音的时间间隔。这样可以计算出来大部分的节奏参数数值,计算时,最好以句子为单位。

#####################################################################################################
#####  适用版本Praat Version 5
#####  Design: Pengfei Shao [email protected]
#####  标注需要两层,一层是CV标记,一层是音节/字
#####################################################################################################
form Dialogue
	comment 请输入文件目录:
	text read_path H:\新建文件夹\select1\wangshihui


	comment  
	comment  
	comment 输入提取目标所在的层级:
	positive reference_tier 2
	comment 输入音节/单词/所在的层级数:
	positive syllable_tier 1
endform

if right$(read_path$,1)<>"\"
	read_path$=read_path$+"\"
endif


Create Strings as file list... fileList 'read_path$'*.TextGrid
result_total$=read_path$+"result_total.txt"
filedelete 'result_total$'
fileappend 'result_total$' fileName'tab$'sum_v'tab$'sum_c'tab$'sum_s'tab$'mean_v'tab$'mean_c'tab$'mean_s'tab$'delta_v'tab$'delta_c'tab$'delta_s'tab$'percent_v'tab$'varco_v'tab$'varco_c'tab$'varco_s'tab$'nPVI_v'tab$'nPVI_c'tab$'nPVI_s'tab$'rPVI_v'tab$'rPVI_c'tab$'rPVI_s'newline$'
numberOfFiles=Get number of strings
for ifile to numberOfFiles
	select Strings fileList
	fileName$=Get string... 'ifile'
	simpleName$=fileName$-".TextGrid"
	Read from file... 'read_path$''fileName$'
	numberOfIntervals=Get number of intervals... 'reference_tier'
	
	cm=1
	vm=1
	for iInterval to numberOfIntervals
		lab$=Get label of interval... 'reference_tier' 'iInterval'
		sTime=Get start point... 'reference_tier' 'iInterval'
		eTime=Get end point... 'reference_tier' 'iInterval'
		duration=eTime-sTime
		####if lab$="C"
		#####元音辅音#######
		#if lab$<>"sp" and lab$<>"sil" and lab$<>"" and lab$<>"silence"
		#	if left$(lab$,1)="a" or left$(lab$,1)="e" or left$(lab$,1)="i" or left$(lab$,1)="o" or left$(lab$,1)="u"
		#		duration_of_vowel'vm'=duration
		#		lab_of_vowel'vm'$=lab$
		#		vm=vm+1
		#	else
		#		duration_of_consonant'cm'=duration
		#		lab_of_consonant'cm'$=lab$
		#		cm=cm+1
		#	endif
		#endif
		###################

		#####元音辅音#######
		if lab$<>"sp" and lab$<>"sil" and lab$<>"" and lab$<>"silence"
			if lab$="V"
				duration_of_vowel'vm'=duration
				lab_of_vowel'vm'$=lab$
				vm=vm+1
			endif
			if lab$="C"
				duration_of_consonant'cm'=duration
				lab_of_consonant'cm'$=lab$
				cm=cm+1
			endif
		endif
		###################
	endfor

	numberOfIntervals_word=Get number of intervals... 'syllable_tier'
	sm=1
	for iInterval to numberOfIntervals_word
		lab_syllable$=Get label of interval... 'syllable_tier' 'iInterval'
		if lab_syllable$<>"sil" and lab_syllable$<>"silence" and lab_syllable$<>""
			sTime_syllable=Get start point... 'syllable_tier' 'iInterval'
			eTime_syllable=Get end point... 'syllable_tier' 'iInterval'
			duration_syllable=eTime_syllable-sTime_syllable
			duration_of_syllable'sm'=duration_syllable
			lab_of_syllable'sm'$=lab_syllable$
			sm=sm+1
		endif
	endfor
	total_c=cm-1
	total_v=vm-1
	total_s=sm-1

	sum_c=0
	sum_v=0
	sum_s=0
	
	
	temp_duration_list_file$=read_path$+simpleName$+"_duration_s.txt"
	duration_list_file_c$=read_path$+simpleName$+"_duration_c.txt"
	duration_list_file_v$=read_path$+simpleName$+"_duration_v.txt"
	filedelete 'duration_list_file_c$'
	fileappend 'duration_list_file_c$' labC'tab$'d_consonant'newline$'
	for ii from 1 to total_c
		temp=duration_of_consonant'ii'
		temp$=lab_of_consonant'ii'$
		sum_c=sum_c+temp
		fileappend 'duration_list_file_c$' 'temp$''tab$''temp''newline$'
	endfor
	filedelete 'duration_list_file_v$'
	fileappend 'duration_list_file_v$' labV'tab$'d_vowel'newline$'
	for jj from 1 to total_v
		temp=duration_of_vowel'jj'
		temp$=lab_of_vowel'jj'$
		sum_v=sum_v+temp
		fileappend 'duration_list_file_v$' 'temp$''tab$''temp''newline$'
	endfor
	filedelete 'temp_duration_list_file$'
	fileappend 'temp_duration_list_file$' labS'tab$'d_syllable'newline$'
	for kk from 1 to total_s
		temp=duration_of_syllable'kk'
		temp$=lab_of_syllable'kk'$
		sum_s=sum_s+temp
		fileappend 'temp_duration_list_file$' 'temp$''tab$''temp''newline$'
	endfor

	Read Table from tab-separated file... 'temp_duration_list_file$'
	txtSsimpleName$=selected$("Table",1)
	Read Table from tab-separated file... 'duration_list_file_c$'
	txtCsimpleName$=selected$("Table",1)
	Read Table from tab-separated file... 'duration_list_file_v$'
	txtVsimpleName$=selected$("Table",1)

	select Table 'txtSsimpleName$'
	mean_S=Get mean... d_syllable
	stdev_S=Get standard deviation... d_syllable

	select Table 'txtCsimpleName$'
	mean_C=Get mean... d_consonant
	stdev_C=Get standard deviation... d_consonant

	select Table 'txtVsimpleName$'
	mean_V=Get mean... d_vowel
	stdev_V=Get standard deviation... d_vowel

	#计算percentage_V
	percent_v=sum_v/sum_s

	#计算Varco
	varcoV=100*(stdev_V/mean_V)
	varcoC=100*(stdev_C/mean_C)
	varcoS=100*(stdev_S/mean_S)

	#计算rPVI_C
	sssC=0
	for i from 1 to total_c-1
		j=i+1
		cdur1=duration_of_consonant'i'
		cdur2=duration_of_consonant'j'
		temp=abs(cdur1-cdur2)
		sssC=sssC+temp
	endfor
	sssC=sssC/(total_c-1)*100
	rPVI_C=sssC

	#计算rPVI_V
	sssV=0
	for i from 1 to total_v-1
		j=i+1
		vdur1=duration_of_vowel'i'
		vdur2=duration_of_vowel'j'
		temp=abs(vdur1-vdur2)
		sssV=sssV+temp
	endfor
	sssV=sssV/(total_v-1)*100
	rPVI_V=sssV
	
	#计算rPVI_S
	sssS=0
	for i from 1 to total_s-1
		j=i+1
		sdur1=duration_of_syllable'i'
		sdur2=duration_of_syllable'j'
		temp=abs(sdur1-sdur2)
		sssS=sssS+temp
	endfor
	sssS=sssS/(total_s-1)*100
	rPVI_S=sssS

	#计算nPVI_C
	ssssC=0
	for i from 1 to total_c-1
		j=i+1
		cdur1=duration_of_consonant'i'
		cdur2=duration_of_consonant'j'
		if cdur1=0 and cdur2=0
			temp=0
		else
			temp=abs((abs(cdur1-cdur2))/((cdur1+cdur2)/2))
		endif	
		ssssC=ssssC+temp
	endfor
	ssssC=ssssC/(total_c-1)*100
	nPVI_C=ssssC
	
	#计算nPVI_V
	ssssV=0
	for i from 1 to total_v-1
		j=i+1
		vdur1=duration_of_vowel'i'
		vdur2=duration_of_vowel'j'
		if vdur1=0 and vdur2=0
			temp=0
		else
			temp=abs((abs(vdur1-vdur2))/((vdur1+vdur2)/2))
		endif	
		ssssV=ssssV+temp
	endfor
	ssssV=ssssV/(total_v-1)*100
	nPVI_V=ssssV

	#计算nPVI_S
	ssssS=0
	for i from 1 to total_s-1
		j=i+1
		sdur1=duration_of_syllable'i'
		sdur2=duration_of_syllable'j'
		if sdur1=0 and sdur2=0
			temp=0
		else
			temp=abs((abs(sdur1-sdur2))/((sdur1+sdur2)/2))
		endif	
		ssssS=ssssS+temp
	endfor
	ssssS=ssssS/(total_s-1)*100
	nPVI_S=ssssS
	
	fileappend 'result_total$' 'simpleName$''tab$''sum_v''tab$''sum_c''tab$''sum_s''tab$''mean_V''tab$''mean_C''tab$''mean_S''tab$''stdev_V''tab$''stdev_C''tab$''stdev_S''tab$''percent_v''tab$''varcoV''tab$''varcoC''tab$''varcoS''tab$''nPVI_V''tab$''nPVI_C''tab$''nPVI_S''tab$''rPVI_V''tab$''rPVI_C''tab$''rPVI_S''newline$'
	select Table 'txtSsimpleName$'
	Remove
	select Table 'txtCsimpleName$'
	Remove
	select Table 'txtVsimpleName$'
	Remove
	select TextGrid 'simpleName$'
	Remove
endfor
select Strings fileList
Remove
exit 脚本结束!



你可能感兴趣的:(Praat根据标注出来的CV标记计算节奏参数)