Miyazawa’s Pukiwiki
Praat
はすでに存在します。
開始行:
#access
#analog
&color(red){2015/08/28 誤記および古い記法を一部修正しまし...
&color(red){2015/02/10 フォルマント解析のパラメータについ...
&color(red){2013/12/11 Praat 5.3.60 に合わせて内容を新し...
*音声解析ソフトウェア Praat((Copyright (C) 1992-2014 by P...
#contents
**ダウンロード [#u9b8fe90]
-[[ここ:http://www.fon.hum.uva.nl/praat/]]から(左上「Dow...
**音声ファイル読み込み&視覚化 [#h963d505]
-まず、Praatを開く。
-Praat Objects ウインドウで、「Open」>「Read from file......
-Praat Objects ウインドウで、右の「View & Edit」を選択 > ...
--「View」>「Zoom in」(もしくは''Ctrl+I'')で拡大、「Vie...
--「Formant」>「Show formants」でフォルマントの推定値(赤...
#ref(praat_edit.jpg,,60%);
--【注】音声ファイルがモノラルの場合は波形は一つ、ステレ...
--【注】ここで表示されるフォルマントやピッチ曲線は、高速...
**音声ファイルの各種情報を得る [#mdf38025]
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
-Query > Get ~ を選択することで各種情報が表示される。
--例えばサンプリング周波数が知りたい場合は、Query > Query...
**変換 [#d65f8fa2]
***サンプリング周波数を変換する [#oac298d5]
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--解説:[[Sound: Resample...:http://www.fon.hum.uva.nl/pr...
-[[Praatスクリプト:http://speechresearch.fiw-web.net/41.h...
#geshi(bash){{
do ("Read from file...", "(ファイルパス)/(ファイル名).wav")
do ("Resample...", 16000, 50)
do ("Save as WAV file...", "(ファイルパス)/(ファイル名)_1...
}}
--【注】Praat右のウインドウで「Modify」>「Override sampl...
--【注】大きなサイズの音声ファイルのサンプリング周波数を...
-大量のファイルを一括処理する方法は[[オブジェクトの削除:h...
**フォルマント解析 [#x669156c]
-[[MATLAB Note/音声の分析/VoiceSauce/フォルマント解析結果...
***指定したファイルのフォルマントの値を取得する [#p32fb10b]
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--パラメータを設定して「OK」
#ref(praat_formant.jpg);
---デフォルト値で 0.0 になっているところは、Praat が適当...
---number of formants はフォルマント解析の精度に大きく影...
--解析が終わると、Praat Objects ウインドウに Formant オブ...
-Praatスクリプトは [[指定した.wavファイルのフォルマント周...
***解析したデータの書き出し(上に続いて実行) [#v043ea2b]
-タブ区切りのテキストファイルで書き出したいとき
--Formant オブジェクトを選択して、ウインドウ右の「Tabulat...
--書き出されたテキストファイル(例)
time(s) nformants F1(Hz) B1(Hz) F2(Hz) B2(Hz) F3(Hz) ...
0.024682 4 1080.832 693.576 1986.333 275.479 2793.186 ...
0.034682 5 256.895 71.533 1186.697 405.533 2104.542 ...
0.044682 5 267.422 58.941 1115.706 444.280 2105.796 ...
0.054682 5 284.791 90.876 1045.615 1249.046 1945.385 ...
...
--Praatスクリプトでの実行方法:[[指定した.wavファイルのフ...
-Praat標準の形式((Formantオブジェクトを書き出したテキスト...
--Formant オブジェクトを選択して、「Save」>「Save as text...
--書き出されたPraat標準の形式のテキストファイル(例)
File type = "ooTextFile"
Object class = "Formant 2"
xmin = 0
xmax = 1.9681875
nx = 981
dx = 0.002
x1 = 0.004093749999999896
maxnFormants = 5
frame []:
frame [1]:
intensity = 2.467072818385887e-07
nFormants = 3
formant []:
formant [1]:
frequency = 1709.0579979105942
bandwidth = 550.5559909690334
formant [2]:
frequency = 2757.1904024912733
bandwidth = 1506.7589741423592
formant [3]:
frequency = 3677.525893148506
bandwidth = 997.3536122646018
frame [2]:
...
--Praatスクリプトでの実行方法:[[指定した.wavファイルのフ...
-Praat標準の形式のファイルを、単純な csv 形式に変換したい...
--Praatスクリプト : [[TextGridの数値の集計(フォルマント...
--Java : &ref(ConvertPraatFormantTxt.java);
---実行例
java ConvertPraatFormantTxt 変換前のファイル名 変換後の...
---実行結果の例
time(s),forment1(Hz),formant2(Hz)
0.004,1709.058,2757.19
0.006,398.766,2138.314
...
***フォルマント解析(burg法)のパラメータについて [#fd57d...
-以下は、公式マニュアル [[Sound: To Formant (burg)...:htt...
--Time step (seconds)
連続的な分析フレームの中心と中心の間の時間。もしも2秒の...
--Maximum number of formants
人のスピーチの大部分を解析するためには、各フレームについ...
---詳しくは[[リンク先:http://www.fon.hum.uva.nl/praat/man...
---[[FAQ: Formant analysis:http://www.fon.hum.uva.nl/praa...
--Maximum formant (Hz)
--Window length (s)
分析ウインドウの(実効的な)長さ。praatはサイドローブが ...
--Pre-emphasis from (Hz)
-最適な Maximum number of formants の検討
--/a/の単独発話ファイル &ref(a.wav); を使って、 Maximum n...
--Praatスクリプトで解析します。
clearinfo
#wavフォルダのパス
directory$ = "E:/Users/m-kouki/Desktop"
#wavファイル名
wavfile$ = "a.wav"
#ファイル読み込み
Read from file: "'directory$'/'wavfile$'"
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = wavfile$ - ".wav"
selectObject: "Sound 'objname$'"
To Formant (burg): 0, 4, 5500, 0.025, 50
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "'directory$'/'objname$'_NoF4.Table"
selectObject: "Sound 'objname$'"
To Formant (burg): 0, 5, 5500, 0.025, 50
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "'directory$'/'objname$'_NoF5.Table"
selectObject: "Sound 'objname$'"
To Formant (burg): 0, 6, 5500, 0.025, 50
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "'directory$'/'objname$'_NoF6.Table"
--a_NoF4.Table, a_NoF5.Table, a_NoF6.Table が書き出される...
#ref(a_NoF.png,,80%);
---Number of Formants の値は小さいほうが、推定結果の値は...
--続いて、日本語話し言葉コーパスの2名の話者が発声した母音...
---音声ファイル [[CSJ_samplevowels.zip:http://shower.huma...
---以下のPraatスクリプトを使います。以下は Number of fotm...
--
clearinfo
#フォルダのパス
directory$ = "E:/Users/m-kouki/Desktop/CSJ_samplevowels"
#出力ファイル名
output$ = "E:/Users/m-kouki/Desktop/CSJ_samplevowels_NoF...
#Number of Formants
number_of_formants = 4
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_toke...
# 開始時間・終了時間を得る
start_time = Get start time
end_time = Get end time
# 時間的中心点の時間を得る
center_time = (end_time - start_time) / 2
# フォルマント解析
do ("To Formant (burg)...", 0.01, 'number_of_formant...
# 時間的中心点の第一・第二フォルマントを得る
formant_one = Get value at time: 1, center_time, "He...
formant_two = Get value at time: 2, center_time, "He...
# 情報ウインドウに表示する
print 'objname$','center_time','formant_one','forman...
# ファイルに出力する
fileappend 'output$' 'objname$','center_time','forma...
#オブジェクトを削除する
Remove
selectObject ("Sound 'objname$'")
Remove
endfor
selectObject ("Strings list")
Remove
---得られた結果をまとめたファイル &ref(CSJ_samplevowels_N...
#geshi(rsplus){{
library(ggplot2)
data <- read.table("E:/Users/m-kouki/Desktop/CSJ_samplevo...
ggplot(data) + geom_point(aes(x=NoF4_F1, y=NoF4_F2, color...
labs(title="Number of formants = 4") + facet_wrap( ~ sp...
xlim(0, 1500) + ylim(500, 3500)
ggplot(data) + geom_point(aes(x=NoF5_F1, y=NoF5_F2, color...
labs(title="Number of formants = 5") + facet_wrap( ~ sp...
xlim(0, 1500) + ylim(500, 3500)
ggplot(data) + geom_point(aes(x=NoF6_F1, y=NoF6_F2, color...
labs(title="Number of formants = 6") + facet_wrap( ~ sp...
xlim(0, 1500) + ylim(500, 3500)
}}
#ref(CSJ_samplevowels_NoF.png,,50%);
---/i/の推定値にかなりのばらつきがあります。[[音声1:http:...
-Number of formants, Maximum formant の値とフォルマント解...
--以下は「二番目が」と発話された音声(女性話者)を解析し...
#ref(NoFandMaxF.png,,50%);
---Number of formants = 6(ピンク)では、F2をF1に間違う例...
---ここで検討したパラメータの中では、Number of formants =...
**ピッチ(基本周波数, F0)解析 [#udbb1c0c]
-[[MATLAB Note/音声の分析/VoiceSauce/F0解析結果の検討:htt...
-参考:[[Praatによる音声分析 (2):http://lab2015.net/doc/w...
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--パラメータを設定して「OK」
#ref(praat_pitch.jpg);
---デフォルト値で 0.0 になっているところは、Praat が適当...
--ピッチ解析のパラメータの詳細は [[To Pitch (ac)...:http:...
---基底ピッチ周波数(pitch floor)はデフォルトでは 75[Hz]...
---ウインドウシフト長(Time step)はデフォルトでは 0.75 /...
--解析が終わると、Praat Objects ウインドウに Pitch オブジ...
---データをタブ区切りで書き出すには、できた Pitch オブジ...
-Praatスクリプトは [[指定したフォルダ内の全.wavファイルの...
**音響インテンシティ解析 [#lefe5826]
-音響インテンシティとは:[[音の進行する方向性を考慮に入れ...
--[[橘秀樹, "音響インテンシティ法による音響測定," 建材試...
-執筆中...
**MFCC解析 [#cae343d4]
-[[MFCC(Praatマニュアル):http://www.fon.hum.uva.nl/praat/...
-[[MFCC解析のツール/MATLAB Auditory Toolbox, Praat, HTK ...
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--パラメータを設定して「OK」
#ref(praat_mfcc.jpg);
-解析が終わると、Praat Objects ウインドウに MFCC オブジェ...
--できた MFCC オブジェクトを選択して、「Save」>「Save as ...
File type = "ooTextFile"
Object class = "MFCC 1"
xmin = 0
xmax = 18.5298125
nx = 3700
dx = 0.005
x1 = 0.017406250000001008
fmin = 100
fmax = 2700
maximumNumberOfCoefficients = 12
frame []:
frame [1]:
numberOfCoefficients = 12
c0 = 24.36560329075726
c []:
c [1] = 82.28431789991208
c [2] = -16.406116271253623
c [3] = 17.948883291899406
c [4] = 26.182123443407328
c [5] = 1.4004139248903602
c [6] = -28.63868916512294
c [7] = 3.456068179796329
c [8] = 10.503555237099786
c [9] = 12.208769119473299
c [10] = -2.552543112600171
c [11] = -16.38476565418306
c [12] = -6.106540020839194
frame [2]:
numberOfCoefficients = 12
c0 = 23.3904395317179
c []:
c [1] = 98.12248910653565
c [2] = -18.160192859174146
c [3] = 31.530121962755366
(以下略)
--データをタブ区切りで書き出すには、できた MFCC オブジェ...
-ファイルの長さがウインドウ長よりある程度長くないと解析に...
--ウインドウ長 = 0.025[s] のとき、0.050[s] のファイルでエ...
--ファイルの持続時間がウインドウ長の2倍「より」大きい値...
-Praatスクリプトは [[指定したフォルダ内の全.wavファイルの...
**発話区間(無音区間)推定(([[西川賢哉 様:http://speechco...
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--Minimum silent interval duration[s] の値は、小さすぎる...
--Silence threshold[dB] の値は、背景雑音の程度によって変...
-TextGridオブジェクトが作られるので、結果を見たければ解析...
--結果を書き出したければ TextGrid オブジェクトを選択して...
--【注】音声ファイルは長すぎるとエラーになってしまうので...
**Praatスクリプトの書き方 [#oebdbd17]
-Praat上で手動で行った分析手順を自動化したい場合(ファイ...
--各処理を行うためのPraatの操作方法は、Praat の Helpを参...
-もう少し複雑な操作をしたい場合はPraatスクリプトを直接編...
-参考:[[Scripting (Praat 公式マニュアル):http://www.fon....
--特にPraatスクリプトで使える関数については、[[Formulas:h...
//--なお、Praatのウェブマニュアルは最新の情報とは限らない...
***メッセージ表示&変数操作&型変換&予約語&文字列操作 [...
-&color(red){2015/08/28 【注】以下で説明している、シング...
-メッセージを表示するには、untitled script ウインドウに以...
#geshi(bash){{
print Hello World!
}}
--「Praat Info」ウインドウが立ち上がり「Hello World!」と...
-変数を操作してみる
#geshi(bash){{
clearinfo
num = 1 + 2
print num
print 'newline$'
print 'num'
}}
--%%シングルクオートで囲まないと変数扱いにならない。
--改行は 'newline$'
--「Praat Info」ウインドウを空白にするには clearinfo を実...
-文字列型と数値型(([[西川賢哉 様:http://speechcorpus.sees...
--名前の最後に「$」がついた変数は文字列として扱われます。
#geshi(bash){{
clearinfo
num1$ = "1" + "2"
num2 = 1 + 2
print 'num1$''newline$''num2'
}}
--文字列型を数値型に変更するには、「num = 'num$'」のよう...
--数値型を文字列型に変更するには、「num$ = "'num'"」のよ...
-予約語として ''newline$''(改行)、''tab$''(タブ)、''s...
#geshi(bash){{
clearinfo
predefined$ = "newline$ : "+newline$+" tab$ : "+tab$+" sh...
print 'predefined$'
}}
-ファイル名がわかっていて拡張子を除去したい場合などは、以...
#geshi(bash){{
clearinfo
filename1$ = "R00M0036.TextGrid"
filename2$ = filename1$ - ".TextGrid"
print 'filename1$''newline$''filename2$''newline$'
#ついでに、ファイル名の冒頭1文字を取得するには
head$ = left$(filename1$,1)
print 'head$'
}}
--その他の文字列操作関数は [[Formulas 5. String functions...
***ファイル入出力 [#j3f45056]
-ファイルを新規で作って文字列を書き出すには、untitled scr...
#geshi(bash){{
#ファイルの新規作成(指定した文字列の書き込み)
output$ = "Hello World!"
output$ > C:\\Users\\miyazawa\\Desktop\\output.txt
}}
--ファイルのディレクトリパスを変数で指定することもできま...
#geshi(bash){{
#ファイルの新規作成(ディレクトリパスを指定して書き込み)
output$ = "Hello World!"
directory$ = "C:\Users\miyazawa\Desktop\"
output$ > 'directory$'output.txt
}}
-ファイルに文字列を追記するには、上に続けて以下を実行しま...
#geshi(bash){{
#追記
fileappend "C:\\Users\\miyazawa\\Desktop\\output.txt" 'ne...
}}
***指定した.wavファイルのフォルマント周波数を求める [#f82...
-C:\sound フォルダのモノラル音声ファイル sound1.wav を読...
do ("Read from file...", "C:/sound/sound1.wav")
selectObject ("Sound sound1")
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
do ("Save as text file...", "C:/sound/sound1.TextGrid")
do ("Remove")
selectObject ("Sound sound1")
do ("Remove")
--To Formant (burg)... の後の値は、[[「Analyse spectrum -...
//--【注】Praatスクリプトでは、「do ("List...", "no", "ye...
-解析した結果をタブ区切りのテキストファイルで書き出したい...
do ("Read from file...", "E:/Users/m-kouki/Desktop/a.wav")
selectObject ("Sound a")
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "E:/Users/m-kouki/Desktop/a.Table"
do ("Remove")
selectObject ("Sound a")
do ("Remove")
***指定したフォルダ内の全.wavファイルの平均ピッチ・ピッチ...
-[[連番のファイルを順番に解析する:http://speechresearch.f...
#geshi(bash){{
clearinfo
#フォルダのパス(書き換えて下さい)
directory$ = "C:/sound"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
do ("To Pitch...", 0.01, 75, 600)
selectObject ("Pitch 'objname$'")
# ピッチの平均値を得る
f_mean = Get mean... 0 0 Hertz
# ピッチの最大値を得る
f_max = Get maximum... 0 0 Hertz Parabolic
# ピッチの最小値を得る
f_min = Get minimum... 0 0 Hertz Parabolic
# ピッチレンジを求める
f_range = f_max - f_min
# 結果をinfoウインドウに出力する
print 'directory$','current_token$','f_mean','f_range...
do ("Remove")
selectObject ("Sound 'objname$'")
do ("Remove")
endfor
}}
***指定したフォルダ内の全.wavファイルのMFCCを求めてテキス...
-[[連番のファイルを順番に解析する:http://speechresearch.f...
-以下では、フレームサイズ25ms、フレームシフトサイズ1msでc...
#geshi(bash){{
clearinfo
#WAVファイルのフォルダパス(書き換えて下さい)
directoryW$ = "C:/sound"
#出力ファイルのフォルダパス(書き換えて下さい)
directoryO$ = "E:\Users\m-kouki\Desktop\MFCCtxt"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directoryW$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directoryW$'/'current_toke...
#このファイルの持続時間を得る
duration = Get total duration
#このファイルの持続時間がフレーム長の2倍より長いとき...
if duration > 0.050
#MFCC解析
do ("To MFCC...", 12, 0.025, 0.001, 100, 100, 0)
selectObject ("MFCC 'objname$'")
#テーブルに書き出す
do ("To TableOfReal...", "no")
do ("Save as headerless spreadsheet file...", "'d...
do ("Remove")
selectObject ("MFCC 'objname$'")
do ("Remove")
endif
selectObject ("Sound 'objname$'")
do ("Remove")
endfor
}}
***連番のファイルを順番に解析する [#z5a9eb9c]
-C:\sound フォルダに入っているモノラルの音声ファイル soun...
--for文で連番のファイル名を指定して順番に処理できます(参...
-untitled script ウインドウに以下を貼り付けて「Run >「Run」
#geshi(bash){{
#フォルダのパス
directory$ = "C:/sound"
#1~3までループ
for i from 1 to 3
#「(フォルダのパス)sound(ループ番号).wav」を読み込む
do ("Read from file...", "'directory$'/sound'i'.wav")
# フォルマント解析
To Formant (burg)... 0.01 5 5500 0.02 50
#「(フォルダのパス)sound(ループ番号).wav」を書きだす
do ("Write to text file...", "'directory$'/sound'i'.T...
# オブジェクトを削除する
Remove
# Soundオブジェクト"sound'i'"を選択する
selectObject ("Sound sound'i'")
Remove
endfor
}}
***特定フォルダ内の全ファイルを順番に解析する [#z5a9eb9c]
-C:\sound フォルダに入っている任意の数・任意の名称の .wav...
-untitled script ウインドウに以下を貼り付けて「Run」>「Ru...
#geshi(bash){{
clearinfo
#フォルダのパス
directory$ = "C:/sound"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
#Praat標準の形式で書きだす
do ("Save as text file...", "'directory$'/'objname$'....
#オブジェクトを削除する
Remove
selectObject ("Sound 'objname$'")
Remove
endfor
selectObject ("Strings list")
Remove
}}
-指定したフォルダから見て3階層下にあるフォルダの中の全て...
#geshi(bash){{
clearinfo
#フォルダのパス(第一階層)
directory_1$ = "C:/sound"
#第一階層のフォルダ内の全てのフォルダ名を取得
Create Strings as directory list... directoryList 'direct...
number_directries_1 = Get number of strings
#各フォルダを順番に処理
for i from 1 to number_directries_1
#第二階層のフォルダ名を取得
selectObject ("Strings directoryList")
thisdirectory_2$ = Get string... 'i'
directory_2$ = directory_1$+"/"+thisdirectory_2$
print lv2: 'directory_2$''newline$'
#第二階層のフォルダ内の全てのフォルダ名を取得
Create Strings as directory list... directoryList 'di...
number_directries_2 = Get number of strings
#各フォルダを順番に処理
for j from 1 to number_directries_2
#第三階層のフォルダ名を取得
selectObject ("Strings directoryList")
thisdirectory_3$ = Get string... 'j'
directory_3$ = directory_2$+"/"+thisdirectory_3$
print lv3: 'directory_3$''newline$'
#第三階層のフォルダ内の全ての.wav形式のファイル名...
Create Strings as file list... list 'directory_3...
number_files = Get number of strings
#各ファイルを順番に処理
for l from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'l'
#.wavファイルを読み込む
Read from file... 'directory_3$'/'current_tok...
#ここで処理を記述する
endfor
selectObject ("Strings list")
Remove
endfor
selectObject ("Strings directoryList")
Remove
endfor
selectObject ("Strings directoryList")
Remove
}}
--このように、大量のファイルを読み込んで処理する場合は、...
***特定フォルダ内の全ファイルの持続時間を得る [#w15dc987]
#geshi(bash){{
clearinfo
directory$ = "(フォルダのパス)"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
output$ = Get total duration
print 'objname$'
print 'output$'
print 'newline$'
#オブジェクトを削除する
selectObject ("Sound 'objname$'")
Remove
endfor
selectObject ("Strings list")
Remove
}}
***TextGridを読み込んで、特定の要素のみを書き出す [#h8ef0...
-ここでは例として、[[日本語話し言葉コーパス:http://www.ni...
--以下のサンプルファイルを使います。((サンプルファイル公...
#ref(CSJsample.TextGrid);
--これは以下のような構造になっています。
File type = "ooTextFile"
Object class = "TextGrid"
(略)
size = 4
item []:
item [1]:
class = "IntervalTier"
name = "word"
xmin = 0
xmax = 1421.7640000000001
intervals: size = 4232
intervals [1]:
xmin = 0
xmax = 7.273889
text = "#"
intervals [2]:
xmin = 7.273889
xmax = 7.737846
text = "(F eH)"
(略)
item [2]:
class = "IntervalTier"
name = "seg"
(略)
item [3]:
class = "TextTier"
name = "break"
(略)
item [4]:
class = "TextTier"
name = "tone"
(略)
---item数はCSJでは7ですが、このサンプルファイルでは4まで...
--C:/sound/CSJsample.TextGrid の item[1](word層)のテキ...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 書きだすファイルを初期化
filedelete ("C:/sound/CSJsample.TextGrid.txt")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'interv...
endfor
selectObject ("TextGrid CSJsample")
Remove
}}
---書きだすとき、「begin_time:3」と書けば小数点以下3位ま...
---以下のようなタブ区切りのファイルが出力されます。
# 0 7.274
(F eH) 7.274 7.738
(略)
---同様の処理をデータテーブルを使って行った結果は[[こちら...
--なお、書きだすファイルの先頭行にヘッダ情報を書き出した...
#geshi(bash){{
#ヘッダを書き出す
header$ = "word"+tab$+"begintime"+tab$+"endtime"+newline$
header$ > C:/sound/CSJsample.TextGrid.txt
}}
---以下のようなタブ区切りのファイルが出力されます。
word begintime endtime
# 0 7.274
(F eH) 7.274 7.738
(略)
--前後の行にアクセスすることも可能です。例えば、直前の wo...
#geshi(bash){{
(略)
# intervals(各要素)を順番に処理していく ※ エラー回避の...
for i from 2 to number_of_intervals - 1
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# item[1] の intervals[i-1](一つ前のword要素)の te...
interval_label_preceding$ = Get label of interval......
# item[1] の intervals[i-1](一つ前のword要素)の xm...
begin_time_preceding = Get starting point... 1 i - 1
# item[1] の intervals[i+1] (一つ後のword要素)の t...
interval_label_following$ = Get label of interval......
# item[1] の intervals[i+1] (一つ後のword要素)の x...
end_time_following = Get end point... 1 i + 1
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'interv...
endfor
(略)
}}
---以下のようなタブ区切りのファイルが出力されます。1列目...
(F eH) 7.274 7.738 # 0 (F eH) 8.214
(F eH) 7.738 8.214 (F eH) 7.274 seNse'H 8.726
seNse'H 8.214 8.726 (F eH) 7.738 no 8.86
no 8.726 8.86 seNse'H 8.214 go 8.973
(略)
***TextGridを読み込んで、指定した条件の値のみを書き出す(...
-if文を使います(参考:[[Example: doing something to ever...
--C:/sound/CSJsample.TextGrid の item[1](word層)を解析...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 書きだすファイルを初期化
filedelete ("C:/sound/CSJsample.TextGrid.txt")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# 持続時間を求める
duration = end_time - begin_time
# 条件判断
if duration >= 0.50
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'i...
endif
endfor
selectObject ("TextGrid CSJsample")
Remove
}}
---結果は以下のようになります(4列目が持続時間)
# 0 7.274 7.274
seNse'H 8.214 8.726 0.512
# 10.991 11.564 0.573
(略)
--複数の条件指定も可能です。0.50[秒]以上に加えて、「"#"以...
#geshi(bash){{
(略)
# 条件判断
if duration >= 0.50 and interval_label$ != "#"
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'i...
endif
(略)
}}
---結果は以下のようになります。
seNse'H 8.214 8.726 0.512
--正規表現で抽出条件を指定することも出来ます。0.40[秒]以...
#geshi(bash){{
(略)
# 条件判断
if duration >= 0.40 and index_regex(interval_label$,...
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'i...
endif
(略)
}}
---index_regexは「第一引数で指定した文字列の中で、第二引...
---「[aeiou]H」は正規表現です(([] は「その中のどれか1文字...
---結果は以下のようになります。
(F eH) 7.274 7.738 0.464
(F eH) 7.738 8.214 0.476
kyoHdoH 11.763 12.174 0.410
--上記の正規表現は、必ず a, e, i, o, u に H が後続する文...
---参考用スクリプト(by [[西川賢哉 様:http://speechcorpus...
#----------------------------------------------
str$ = "kawai'H"
clearinfo
if index_regex(str$,"[aiueo]'?H") <> 0
appendInfoLine: str$
endif
#----------------------------------------------
--その他の文字列操作関数は [[Formulas 5. String functions...
***指定した時間区間の切り出しと解析 [#gc250001]
-C:\sound フォルダに入っている sound1.wav を読み込んで、1...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/sound1.wav")
selectObject ("Sound sound1")
do ("Extract part...", 1.100, 1.600, "rectangular", 1, "n...
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
do ("Save as text file...", "C:/sound/sound1_soundpart.Te...
select all
Remove
}}
//--Extract part... の時間(第一・第二引数)を変数で指定...
--第三引数のRectangularは(おそらく)方形窓で切り出し。(...
-C:\sound フォルダに入っている sound1.wav を読み込んで、...
clearinfo
# ファイルを読み込む
do ("Read from file...", "C:/sound/sound1.wav")
selectObject ("Sound sound1")
# 開始時間・終了時間を得る
start_time = Get start time
end_time = Get end time
# 時間的中心点の時間を得る
center_time = (end_time - start_time) / 2
# フォルマント解析
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
# 時間的中心点の第一・第二フォルマントを得る
formant_one = Get value at time: 1, center_time, "Hertz"...
formant_two = Get value at time: 2, center_time, "Hertz"...
# 情報ウインドウに表示する
print 'center_time','formant_one','formant_two''newline$'
# メモリ開放
Remove
selectObject ("Sound sound1")
Remove
--結果は以下のようになります。
0.11665532879818594,630.9603036852504,1192.343426813945
***指定した時間を含むTier要素の抽出 [#lfc3f7c9]
-C:\sound フォルダに入っている &ref(CSJsample.TextGrid); ...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 3.200[秒]の時点を含むword要素のインデックス番号を得る(...
word_index = Get interval at time... 1 3.200
# そのラベルと開始・終了時間を得る(第一引数はitem番号)
word$ = Get label of interval... 1 word_index
begin_time = Get starting point... 1 word_index
end_time = Get end point... 1 word_index
print 'word$''newline$''begin_time''newline$''end_time'
selectObject ("TextGrid CSJsample")
Remove
}}
***TextGridのTier間の照合 [#k5165d07]
-[[TextGridを読み込んで、特定の要素のみを書き出す:http://...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 書きだすファイルを初期化
filedelete ("C:/sound/CSJsample.TextGrid.txt")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# end_time と item[3](break層)の各要素の時間を比較...
break_index = Get nearest index from time... 3 end_t...
# item[3](break層)の break_index 番目の要素のラベ...
boundary$ = Get label of point... 3 break_index
# item[3](break層)の break_index 番目の要素の時間...
boundary_time = Get time of point... 3 break_index
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'interv...
endfor
selectObject ("TextGrid CSJsample")
Remove
}}
--結果は以下のようになります。
# 7.274 F 7.738
(F eH) 7.738 F 7.738
(F eH) 8.214 F 8.214
---2列目がword層の終了時間、新しく追記された3列目がbrake...
***TextGridの数値の集計(フォルマント) [#ha0d4707]
-[[ここ:http://speechresearch.fiw-web.net/index.php?Praat...
#geshi(bash){{
clearinfo
# ファイルを読み込む
do ("Read from file...", "C:/sound/sound1.TextGrid")
# フォルマント型のTextGridであれば、以下のオブジェクトが...
selectObject ("Formant sound1")
# 第二フォルマントの1.500[秒]時点の値を得る
f_two_point = Get value at time... 2 0.150 Hertz Linear
print 'f_two_point''newline$'
# 第二フォルマントの平均値を得る
f_two_mean = Get mean... 2 0 0 Hertz
print 'f_two_mean''newline$'
# 第二フォルマントの中央値を得る
f_two_median = Get quantile... 2 0 0 Hertz 0.50
print 'f_two_median''newline$'
# 第二フォルマントの最大値を得る
f_two_max = Get maximum... 2 0 0 Hertz Parabolic
print 'f_two_max''newline$'
# 第二フォルマントの最小値を得る
f_two_min = Get minimum... 2 0 0 Hertz Parabolic
print 'f_two_min''newline$'
Remove
}}
--各処理の引数の「0 0」に任意の開始時間、終了時間を与える...
--Formant: Get value at time... コマンドは、指定した時間...
--各処理の詳細、およびその他のフォルマント型のオブジェク...
***TextGridの数値の集計(ピッチ) [#k68bbabf]
-[[TextGridの集計(フォルマント):http://speechresearch.f...
--ピッチ型のオブジェクトに対して実行可能な操作は、公式マ...
***データテーブルを作る [#oaa55a09]
-Praat では New > Tables > Create Table with column names...
--[[TextGridを読み込んで、特定の要素のみを書き出す:http:/...
#geshi(bash){{
# テーブルを作る
word_table = Create Table with column names... word_table...
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# テーブルに各要素を代入
selectObject ("Table word_table")
Set string value... i table_word_label 'interval_lab...
Set string value... i table_begin_time 'begin_time'
Set string value... i table_end_time 'end_time'
# テーブルの行数を増やす
Append row
endfor
selectObject ("TextGrid CSJsample")
Remove
# テーブルをタブ区切りで保存
selectObject ("Table word_table")
do ("Save as tab-separated file...", "C:/sound/word_table...
Remove
}}
---「Create Table with column names...」の第一引数はテー...
---実行すると Praat Objectsウインドウに Tableオブジェクト...
#ref(Praat_tablesample01.png,,70%);
---また、タブ区切りのテキストファイル word_table.txt が保...
***オブジェクトの削除(Remove) [#xf9054c6]
-【注】以下はオブジェクト名を使ったやり方です。''「音声コ...
-大量のwavファイルを順番に処理するときなどは、オブジェク...
-Removeコマンドを使います。
--例:C:\sound フォルダに入っている全ての .wav 形式ファイ...
#geshi(bash){{
#フォルダのパス
directory$ = "C:/sound/"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
#このオブジェクトの名前を得ておく
info$ = Info
objectname$ = extractLine$(info$, "Object name: ")
#サンプリング周波数を変換する
Resample... 16000 50
do ("Write to WAV file...", "'directory$'/'objectname...
print wav: 'directory$'/'objectname$'_16000.wav'newli...
#サンプリング周波数変換後のオブジェクトを削除する
Remove
#サンプリング周波数変換前のオブジェクトを削除する
selectObject ("Sound 'objectname$'")
Remove
endfor
selectObject ("Strings list")
Remove
}}
---オブジェクトが作られた直後であれば、そのオブジェクトが...
---listオブジェクトであれば、オブジェクト名は「Strings li...
--Soundオブジェクト名は、「Sound (拡張子を除いたそのファ...
**音素自動ラベリング(音声認識)との連携 [#l9746598]
-音素自動ラベリングの結果をPraat標準の形式に変換してPraat...
-Julius((Copyright (c) 1991-2009 京都大学 河原研究室, Cop...
--[[JuliusとJulian/音素自動ラベリング:http://speechresear...
-HTK の HVite コマンドによる方法
--[[HTKによる音響モデル構築/自動ラベリング:http://speechr...
-'''[[西川先生作成の音素ラベリング自動化ツール:http://sho...
**Tips [#t10149ad]
***メモリーオーバーエラーが出て解析が止まってしまったとき...
-[[オブジェクトの削除:http://speechresearch.fiw-web.net/4...
-仮想メモリの上限を上げる。常駐ソフトを停止させる。エクス...
-メモリ容量の大きいPCを使うのが一番手っ取り早いようです。
-重たい解析(リサンプリングや、短い窓長でフォルマント解析...
--[[指定した時間区間の切り出しと解析:http://speechresearc...
***半角括弧「(」「)」をファイル名に含む場合 [#q201b90d]
-半角括弧のファイル名は、Praatオブジェクトに取り込まれた...
-Praatスクリプトでオブジェクト名を指定する場合、例えば以...
#geshi(bash){{
(略)
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#ファイル名の半角括弧はオブジェクト名では「_」に置換される
objname$ = replace$ (objname$, "(", "_", 0)
objname$ = replace$ (objname$, ")", "_", 0)
(略)
}}
***コマンドラインで Praat を実行したいとき [#g6beae09]
-[[sendpraat.exe:http://www.fon.hum.uva.nl/praat/sendpraa...
-sendpraatの引数としてPraatスクリプトを指定すればOK.
***録音とラベリング [#y401615e]
-北原先生の [[Praat Tutorial:http://www.f.waseda.jp/kitah...
***動画ラベリングツールとの連携 [#mec9d57f]
-[[ELAN:http://speechresearch.fiw-web.net/16.html]] がPra...
***TSV/CSVデータファイルから .TextGrid ファイルを生成する...
-参考:[[Praatの音声アノテーション(.TextGrid)を自動生成...
-- [[TextGridConverter:https://github.com/Syuparn/TextGri...
**リンク [#fdd7fe63]
-[[Paul Boersma's writings on the Praat program:http://ww...
-[[Praat Tutorial:http://www.f.waseda.jp/kitahara/Notes/p...
-[[Akira Utsugi's web site Praat入門:https://sites.google...
--[[マルソリ・ラボ 研究関連メモ(Praat):http://utsakr.bl...
-[[PraatLauncher:http://language.world.coocan.jp/scripts/...
終了行:
#access
#analog
&color(red){2015/08/28 誤記および古い記法を一部修正しまし...
&color(red){2015/02/10 フォルマント解析のパラメータについ...
&color(red){2013/12/11 Praat 5.3.60 に合わせて内容を新し...
*音声解析ソフトウェア Praat((Copyright (C) 1992-2014 by P...
#contents
**ダウンロード [#u9b8fe90]
-[[ここ:http://www.fon.hum.uva.nl/praat/]]から(左上「Dow...
**音声ファイル読み込み&視覚化 [#h963d505]
-まず、Praatを開く。
-Praat Objects ウインドウで、「Open」>「Read from file......
-Praat Objects ウインドウで、右の「View & Edit」を選択 > ...
--「View」>「Zoom in」(もしくは''Ctrl+I'')で拡大、「Vie...
--「Formant」>「Show formants」でフォルマントの推定値(赤...
#ref(praat_edit.jpg,,60%);
--【注】音声ファイルがモノラルの場合は波形は一つ、ステレ...
--【注】ここで表示されるフォルマントやピッチ曲線は、高速...
**音声ファイルの各種情報を得る [#mdf38025]
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
-Query > Get ~ を選択することで各種情報が表示される。
--例えばサンプリング周波数が知りたい場合は、Query > Query...
**変換 [#d65f8fa2]
***サンプリング周波数を変換する [#oac298d5]
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--解説:[[Sound: Resample...:http://www.fon.hum.uva.nl/pr...
-[[Praatスクリプト:http://speechresearch.fiw-web.net/41.h...
#geshi(bash){{
do ("Read from file...", "(ファイルパス)/(ファイル名).wav")
do ("Resample...", 16000, 50)
do ("Save as WAV file...", "(ファイルパス)/(ファイル名)_1...
}}
--【注】Praat右のウインドウで「Modify」>「Override sampl...
--【注】大きなサイズの音声ファイルのサンプリング周波数を...
-大量のファイルを一括処理する方法は[[オブジェクトの削除:h...
**フォルマント解析 [#x669156c]
-[[MATLAB Note/音声の分析/VoiceSauce/フォルマント解析結果...
***指定したファイルのフォルマントの値を取得する [#p32fb10b]
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--パラメータを設定して「OK」
#ref(praat_formant.jpg);
---デフォルト値で 0.0 になっているところは、Praat が適当...
---number of formants はフォルマント解析の精度に大きく影...
--解析が終わると、Praat Objects ウインドウに Formant オブ...
-Praatスクリプトは [[指定した.wavファイルのフォルマント周...
***解析したデータの書き出し(上に続いて実行) [#v043ea2b]
-タブ区切りのテキストファイルで書き出したいとき
--Formant オブジェクトを選択して、ウインドウ右の「Tabulat...
--書き出されたテキストファイル(例)
time(s) nformants F1(Hz) B1(Hz) F2(Hz) B2(Hz) F3(Hz) ...
0.024682 4 1080.832 693.576 1986.333 275.479 2793.186 ...
0.034682 5 256.895 71.533 1186.697 405.533 2104.542 ...
0.044682 5 267.422 58.941 1115.706 444.280 2105.796 ...
0.054682 5 284.791 90.876 1045.615 1249.046 1945.385 ...
...
--Praatスクリプトでの実行方法:[[指定した.wavファイルのフ...
-Praat標準の形式((Formantオブジェクトを書き出したテキスト...
--Formant オブジェクトを選択して、「Save」>「Save as text...
--書き出されたPraat標準の形式のテキストファイル(例)
File type = "ooTextFile"
Object class = "Formant 2"
xmin = 0
xmax = 1.9681875
nx = 981
dx = 0.002
x1 = 0.004093749999999896
maxnFormants = 5
frame []:
frame [1]:
intensity = 2.467072818385887e-07
nFormants = 3
formant []:
formant [1]:
frequency = 1709.0579979105942
bandwidth = 550.5559909690334
formant [2]:
frequency = 2757.1904024912733
bandwidth = 1506.7589741423592
formant [3]:
frequency = 3677.525893148506
bandwidth = 997.3536122646018
frame [2]:
...
--Praatスクリプトでの実行方法:[[指定した.wavファイルのフ...
-Praat標準の形式のファイルを、単純な csv 形式に変換したい...
--Praatスクリプト : [[TextGridの数値の集計(フォルマント...
--Java : &ref(ConvertPraatFormantTxt.java);
---実行例
java ConvertPraatFormantTxt 変換前のファイル名 変換後の...
---実行結果の例
time(s),forment1(Hz),formant2(Hz)
0.004,1709.058,2757.19
0.006,398.766,2138.314
...
***フォルマント解析(burg法)のパラメータについて [#fd57d...
-以下は、公式マニュアル [[Sound: To Formant (burg)...:htt...
--Time step (seconds)
連続的な分析フレームの中心と中心の間の時間。もしも2秒の...
--Maximum number of formants
人のスピーチの大部分を解析するためには、各フレームについ...
---詳しくは[[リンク先:http://www.fon.hum.uva.nl/praat/man...
---[[FAQ: Formant analysis:http://www.fon.hum.uva.nl/praa...
--Maximum formant (Hz)
--Window length (s)
分析ウインドウの(実効的な)長さ。praatはサイドローブが ...
--Pre-emphasis from (Hz)
-最適な Maximum number of formants の検討
--/a/の単独発話ファイル &ref(a.wav); を使って、 Maximum n...
--Praatスクリプトで解析します。
clearinfo
#wavフォルダのパス
directory$ = "E:/Users/m-kouki/Desktop"
#wavファイル名
wavfile$ = "a.wav"
#ファイル読み込み
Read from file: "'directory$'/'wavfile$'"
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = wavfile$ - ".wav"
selectObject: "Sound 'objname$'"
To Formant (burg): 0, 4, 5500, 0.025, 50
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "'directory$'/'objname$'_NoF4.Table"
selectObject: "Sound 'objname$'"
To Formant (burg): 0, 5, 5500, 0.025, 50
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "'directory$'/'objname$'_NoF5.Table"
selectObject: "Sound 'objname$'"
To Formant (burg): 0, 6, 5500, 0.025, 50
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "'directory$'/'objname$'_NoF6.Table"
--a_NoF4.Table, a_NoF5.Table, a_NoF6.Table が書き出される...
#ref(a_NoF.png,,80%);
---Number of Formants の値は小さいほうが、推定結果の値は...
--続いて、日本語話し言葉コーパスの2名の話者が発声した母音...
---音声ファイル [[CSJ_samplevowels.zip:http://shower.huma...
---以下のPraatスクリプトを使います。以下は Number of fotm...
--
clearinfo
#フォルダのパス
directory$ = "E:/Users/m-kouki/Desktop/CSJ_samplevowels"
#出力ファイル名
output$ = "E:/Users/m-kouki/Desktop/CSJ_samplevowels_NoF...
#Number of Formants
number_of_formants = 4
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_toke...
# 開始時間・終了時間を得る
start_time = Get start time
end_time = Get end time
# 時間的中心点の時間を得る
center_time = (end_time - start_time) / 2
# フォルマント解析
do ("To Formant (burg)...", 0.01, 'number_of_formant...
# 時間的中心点の第一・第二フォルマントを得る
formant_one = Get value at time: 1, center_time, "He...
formant_two = Get value at time: 2, center_time, "He...
# 情報ウインドウに表示する
print 'objname$','center_time','formant_one','forman...
# ファイルに出力する
fileappend 'output$' 'objname$','center_time','forma...
#オブジェクトを削除する
Remove
selectObject ("Sound 'objname$'")
Remove
endfor
selectObject ("Strings list")
Remove
---得られた結果をまとめたファイル &ref(CSJ_samplevowels_N...
#geshi(rsplus){{
library(ggplot2)
data <- read.table("E:/Users/m-kouki/Desktop/CSJ_samplevo...
ggplot(data) + geom_point(aes(x=NoF4_F1, y=NoF4_F2, color...
labs(title="Number of formants = 4") + facet_wrap( ~ sp...
xlim(0, 1500) + ylim(500, 3500)
ggplot(data) + geom_point(aes(x=NoF5_F1, y=NoF5_F2, color...
labs(title="Number of formants = 5") + facet_wrap( ~ sp...
xlim(0, 1500) + ylim(500, 3500)
ggplot(data) + geom_point(aes(x=NoF6_F1, y=NoF6_F2, color...
labs(title="Number of formants = 6") + facet_wrap( ~ sp...
xlim(0, 1500) + ylim(500, 3500)
}}
#ref(CSJ_samplevowels_NoF.png,,50%);
---/i/の推定値にかなりのばらつきがあります。[[音声1:http:...
-Number of formants, Maximum formant の値とフォルマント解...
--以下は「二番目が」と発話された音声(女性話者)を解析し...
#ref(NoFandMaxF.png,,50%);
---Number of formants = 6(ピンク)では、F2をF1に間違う例...
---ここで検討したパラメータの中では、Number of formants =...
**ピッチ(基本周波数, F0)解析 [#udbb1c0c]
-[[MATLAB Note/音声の分析/VoiceSauce/F0解析結果の検討:htt...
-参考:[[Praatによる音声分析 (2):http://lab2015.net/doc/w...
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--パラメータを設定して「OK」
#ref(praat_pitch.jpg);
---デフォルト値で 0.0 になっているところは、Praat が適当...
--ピッチ解析のパラメータの詳細は [[To Pitch (ac)...:http:...
---基底ピッチ周波数(pitch floor)はデフォルトでは 75[Hz]...
---ウインドウシフト長(Time step)はデフォルトでは 0.75 /...
--解析が終わると、Praat Objects ウインドウに Pitch オブジ...
---データをタブ区切りで書き出すには、できた Pitch オブジ...
-Praatスクリプトは [[指定したフォルダ内の全.wavファイルの...
**音響インテンシティ解析 [#lefe5826]
-音響インテンシティとは:[[音の進行する方向性を考慮に入れ...
--[[橘秀樹, "音響インテンシティ法による音響測定," 建材試...
-執筆中...
**MFCC解析 [#cae343d4]
-[[MFCC(Praatマニュアル):http://www.fon.hum.uva.nl/praat/...
-[[MFCC解析のツール/MATLAB Auditory Toolbox, Praat, HTK ...
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--パラメータを設定して「OK」
#ref(praat_mfcc.jpg);
-解析が終わると、Praat Objects ウインドウに MFCC オブジェ...
--できた MFCC オブジェクトを選択して、「Save」>「Save as ...
File type = "ooTextFile"
Object class = "MFCC 1"
xmin = 0
xmax = 18.5298125
nx = 3700
dx = 0.005
x1 = 0.017406250000001008
fmin = 100
fmax = 2700
maximumNumberOfCoefficients = 12
frame []:
frame [1]:
numberOfCoefficients = 12
c0 = 24.36560329075726
c []:
c [1] = 82.28431789991208
c [2] = -16.406116271253623
c [3] = 17.948883291899406
c [4] = 26.182123443407328
c [5] = 1.4004139248903602
c [6] = -28.63868916512294
c [7] = 3.456068179796329
c [8] = 10.503555237099786
c [9] = 12.208769119473299
c [10] = -2.552543112600171
c [11] = -16.38476565418306
c [12] = -6.106540020839194
frame [2]:
numberOfCoefficients = 12
c0 = 23.3904395317179
c []:
c [1] = 98.12248910653565
c [2] = -18.160192859174146
c [3] = 31.530121962755366
(以下略)
--データをタブ区切りで書き出すには、できた MFCC オブジェ...
-ファイルの長さがウインドウ長よりある程度長くないと解析に...
--ウインドウ長 = 0.025[s] のとき、0.050[s] のファイルでエ...
--ファイルの持続時間がウインドウ長の2倍「より」大きい値...
-Praatスクリプトは [[指定したフォルダ内の全.wavファイルの...
**発話区間(無音区間)推定(([[西川賢哉 様:http://speechco...
-[[音声ファイルを読み込み:http://speechresearch.fiw-web.n...
--Minimum silent interval duration[s] の値は、小さすぎる...
--Silence threshold[dB] の値は、背景雑音の程度によって変...
-TextGridオブジェクトが作られるので、結果を見たければ解析...
--結果を書き出したければ TextGrid オブジェクトを選択して...
--【注】音声ファイルは長すぎるとエラーになってしまうので...
**Praatスクリプトの書き方 [#oebdbd17]
-Praat上で手動で行った分析手順を自動化したい場合(ファイ...
--各処理を行うためのPraatの操作方法は、Praat の Helpを参...
-もう少し複雑な操作をしたい場合はPraatスクリプトを直接編...
-参考:[[Scripting (Praat 公式マニュアル):http://www.fon....
--特にPraatスクリプトで使える関数については、[[Formulas:h...
//--なお、Praatのウェブマニュアルは最新の情報とは限らない...
***メッセージ表示&変数操作&型変換&予約語&文字列操作 [...
-&color(red){2015/08/28 【注】以下で説明している、シング...
-メッセージを表示するには、untitled script ウインドウに以...
#geshi(bash){{
print Hello World!
}}
--「Praat Info」ウインドウが立ち上がり「Hello World!」と...
-変数を操作してみる
#geshi(bash){{
clearinfo
num = 1 + 2
print num
print 'newline$'
print 'num'
}}
--%%シングルクオートで囲まないと変数扱いにならない。
--改行は 'newline$'
--「Praat Info」ウインドウを空白にするには clearinfo を実...
-文字列型と数値型(([[西川賢哉 様:http://speechcorpus.sees...
--名前の最後に「$」がついた変数は文字列として扱われます。
#geshi(bash){{
clearinfo
num1$ = "1" + "2"
num2 = 1 + 2
print 'num1$''newline$''num2'
}}
--文字列型を数値型に変更するには、「num = 'num$'」のよう...
--数値型を文字列型に変更するには、「num$ = "'num'"」のよ...
-予約語として ''newline$''(改行)、''tab$''(タブ)、''s...
#geshi(bash){{
clearinfo
predefined$ = "newline$ : "+newline$+" tab$ : "+tab$+" sh...
print 'predefined$'
}}
-ファイル名がわかっていて拡張子を除去したい場合などは、以...
#geshi(bash){{
clearinfo
filename1$ = "R00M0036.TextGrid"
filename2$ = filename1$ - ".TextGrid"
print 'filename1$''newline$''filename2$''newline$'
#ついでに、ファイル名の冒頭1文字を取得するには
head$ = left$(filename1$,1)
print 'head$'
}}
--その他の文字列操作関数は [[Formulas 5. String functions...
***ファイル入出力 [#j3f45056]
-ファイルを新規で作って文字列を書き出すには、untitled scr...
#geshi(bash){{
#ファイルの新規作成(指定した文字列の書き込み)
output$ = "Hello World!"
output$ > C:\\Users\\miyazawa\\Desktop\\output.txt
}}
--ファイルのディレクトリパスを変数で指定することもできま...
#geshi(bash){{
#ファイルの新規作成(ディレクトリパスを指定して書き込み)
output$ = "Hello World!"
directory$ = "C:\Users\miyazawa\Desktop\"
output$ > 'directory$'output.txt
}}
-ファイルに文字列を追記するには、上に続けて以下を実行しま...
#geshi(bash){{
#追記
fileappend "C:\\Users\\miyazawa\\Desktop\\output.txt" 'ne...
}}
***指定した.wavファイルのフォルマント周波数を求める [#f82...
-C:\sound フォルダのモノラル音声ファイル sound1.wav を読...
do ("Read from file...", "C:/sound/sound1.wav")
selectObject ("Sound sound1")
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
do ("Save as text file...", "C:/sound/sound1.TextGrid")
do ("Remove")
selectObject ("Sound sound1")
do ("Remove")
--To Formant (burg)... の後の値は、[[「Analyse spectrum -...
//--【注】Praatスクリプトでは、「do ("List...", "no", "ye...
-解析した結果をタブ区切りのテキストファイルで書き出したい...
do ("Read from file...", "E:/Users/m-kouki/Desktop/a.wav")
selectObject ("Sound a")
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
Down to Table... no yes 6 no 3 yes 3 yes
Write to table file: "E:/Users/m-kouki/Desktop/a.Table"
do ("Remove")
selectObject ("Sound a")
do ("Remove")
***指定したフォルダ内の全.wavファイルの平均ピッチ・ピッチ...
-[[連番のファイルを順番に解析する:http://speechresearch.f...
#geshi(bash){{
clearinfo
#フォルダのパス(書き換えて下さい)
directory$ = "C:/sound"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
do ("To Pitch...", 0.01, 75, 600)
selectObject ("Pitch 'objname$'")
# ピッチの平均値を得る
f_mean = Get mean... 0 0 Hertz
# ピッチの最大値を得る
f_max = Get maximum... 0 0 Hertz Parabolic
# ピッチの最小値を得る
f_min = Get minimum... 0 0 Hertz Parabolic
# ピッチレンジを求める
f_range = f_max - f_min
# 結果をinfoウインドウに出力する
print 'directory$','current_token$','f_mean','f_range...
do ("Remove")
selectObject ("Sound 'objname$'")
do ("Remove")
endfor
}}
***指定したフォルダ内の全.wavファイルのMFCCを求めてテキス...
-[[連番のファイルを順番に解析する:http://speechresearch.f...
-以下では、フレームサイズ25ms、フレームシフトサイズ1msでc...
#geshi(bash){{
clearinfo
#WAVファイルのフォルダパス(書き換えて下さい)
directoryW$ = "C:/sound"
#出力ファイルのフォルダパス(書き換えて下さい)
directoryO$ = "E:\Users\m-kouki\Desktop\MFCCtxt"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directoryW$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directoryW$'/'current_toke...
#このファイルの持続時間を得る
duration = Get total duration
#このファイルの持続時間がフレーム長の2倍より長いとき...
if duration > 0.050
#MFCC解析
do ("To MFCC...", 12, 0.025, 0.001, 100, 100, 0)
selectObject ("MFCC 'objname$'")
#テーブルに書き出す
do ("To TableOfReal...", "no")
do ("Save as headerless spreadsheet file...", "'d...
do ("Remove")
selectObject ("MFCC 'objname$'")
do ("Remove")
endif
selectObject ("Sound 'objname$'")
do ("Remove")
endfor
}}
***連番のファイルを順番に解析する [#z5a9eb9c]
-C:\sound フォルダに入っているモノラルの音声ファイル soun...
--for文で連番のファイル名を指定して順番に処理できます(参...
-untitled script ウインドウに以下を貼り付けて「Run >「Run」
#geshi(bash){{
#フォルダのパス
directory$ = "C:/sound"
#1~3までループ
for i from 1 to 3
#「(フォルダのパス)sound(ループ番号).wav」を読み込む
do ("Read from file...", "'directory$'/sound'i'.wav")
# フォルマント解析
To Formant (burg)... 0.01 5 5500 0.02 50
#「(フォルダのパス)sound(ループ番号).wav」を書きだす
do ("Write to text file...", "'directory$'/sound'i'.T...
# オブジェクトを削除する
Remove
# Soundオブジェクト"sound'i'"を選択する
selectObject ("Sound sound'i'")
Remove
endfor
}}
***特定フォルダ内の全ファイルを順番に解析する [#z5a9eb9c]
-C:\sound フォルダに入っている任意の数・任意の名称の .wav...
-untitled script ウインドウに以下を貼り付けて「Run」>「Ru...
#geshi(bash){{
clearinfo
#フォルダのパス
directory$ = "C:/sound"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
#Praat標準の形式で書きだす
do ("Save as text file...", "'directory$'/'objname$'....
#オブジェクトを削除する
Remove
selectObject ("Sound 'objname$'")
Remove
endfor
selectObject ("Strings list")
Remove
}}
-指定したフォルダから見て3階層下にあるフォルダの中の全て...
#geshi(bash){{
clearinfo
#フォルダのパス(第一階層)
directory_1$ = "C:/sound"
#第一階層のフォルダ内の全てのフォルダ名を取得
Create Strings as directory list... directoryList 'direct...
number_directries_1 = Get number of strings
#各フォルダを順番に処理
for i from 1 to number_directries_1
#第二階層のフォルダ名を取得
selectObject ("Strings directoryList")
thisdirectory_2$ = Get string... 'i'
directory_2$ = directory_1$+"/"+thisdirectory_2$
print lv2: 'directory_2$''newline$'
#第二階層のフォルダ内の全てのフォルダ名を取得
Create Strings as directory list... directoryList 'di...
number_directries_2 = Get number of strings
#各フォルダを順番に処理
for j from 1 to number_directries_2
#第三階層のフォルダ名を取得
selectObject ("Strings directoryList")
thisdirectory_3$ = Get string... 'j'
directory_3$ = directory_2$+"/"+thisdirectory_3$
print lv3: 'directory_3$''newline$'
#第三階層のフォルダ内の全ての.wav形式のファイル名...
Create Strings as file list... list 'directory_3...
number_files = Get number of strings
#各ファイルを順番に処理
for l from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'l'
#.wavファイルを読み込む
Read from file... 'directory_3$'/'current_tok...
#ここで処理を記述する
endfor
selectObject ("Strings list")
Remove
endfor
selectObject ("Strings directoryList")
Remove
endfor
selectObject ("Strings directoryList")
Remove
}}
--このように、大量のファイルを読み込んで処理する場合は、...
***特定フォルダ内の全ファイルの持続時間を得る [#w15dc987]
#geshi(bash){{
clearinfo
directory$ = "(フォルダのパス)"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
output$ = Get total duration
print 'objname$'
print 'output$'
print 'newline$'
#オブジェクトを削除する
selectObject ("Sound 'objname$'")
Remove
endfor
selectObject ("Strings list")
Remove
}}
***TextGridを読み込んで、特定の要素のみを書き出す [#h8ef0...
-ここでは例として、[[日本語話し言葉コーパス:http://www.ni...
--以下のサンプルファイルを使います。((サンプルファイル公...
#ref(CSJsample.TextGrid);
--これは以下のような構造になっています。
File type = "ooTextFile"
Object class = "TextGrid"
(略)
size = 4
item []:
item [1]:
class = "IntervalTier"
name = "word"
xmin = 0
xmax = 1421.7640000000001
intervals: size = 4232
intervals [1]:
xmin = 0
xmax = 7.273889
text = "#"
intervals [2]:
xmin = 7.273889
xmax = 7.737846
text = "(F eH)"
(略)
item [2]:
class = "IntervalTier"
name = "seg"
(略)
item [3]:
class = "TextTier"
name = "break"
(略)
item [4]:
class = "TextTier"
name = "tone"
(略)
---item数はCSJでは7ですが、このサンプルファイルでは4まで...
--C:/sound/CSJsample.TextGrid の item[1](word層)のテキ...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 書きだすファイルを初期化
filedelete ("C:/sound/CSJsample.TextGrid.txt")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'interv...
endfor
selectObject ("TextGrid CSJsample")
Remove
}}
---書きだすとき、「begin_time:3」と書けば小数点以下3位ま...
---以下のようなタブ区切りのファイルが出力されます。
# 0 7.274
(F eH) 7.274 7.738
(略)
---同様の処理をデータテーブルを使って行った結果は[[こちら...
--なお、書きだすファイルの先頭行にヘッダ情報を書き出した...
#geshi(bash){{
#ヘッダを書き出す
header$ = "word"+tab$+"begintime"+tab$+"endtime"+newline$
header$ > C:/sound/CSJsample.TextGrid.txt
}}
---以下のようなタブ区切りのファイルが出力されます。
word begintime endtime
# 0 7.274
(F eH) 7.274 7.738
(略)
--前後の行にアクセスすることも可能です。例えば、直前の wo...
#geshi(bash){{
(略)
# intervals(各要素)を順番に処理していく ※ エラー回避の...
for i from 2 to number_of_intervals - 1
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# item[1] の intervals[i-1](一つ前のword要素)の te...
interval_label_preceding$ = Get label of interval......
# item[1] の intervals[i-1](一つ前のword要素)の xm...
begin_time_preceding = Get starting point... 1 i - 1
# item[1] の intervals[i+1] (一つ後のword要素)の t...
interval_label_following$ = Get label of interval......
# item[1] の intervals[i+1] (一つ後のword要素)の x...
end_time_following = Get end point... 1 i + 1
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'interv...
endfor
(略)
}}
---以下のようなタブ区切りのファイルが出力されます。1列目...
(F eH) 7.274 7.738 # 0 (F eH) 8.214
(F eH) 7.738 8.214 (F eH) 7.274 seNse'H 8.726
seNse'H 8.214 8.726 (F eH) 7.738 no 8.86
no 8.726 8.86 seNse'H 8.214 go 8.973
(略)
***TextGridを読み込んで、指定した条件の値のみを書き出す(...
-if文を使います(参考:[[Example: doing something to ever...
--C:/sound/CSJsample.TextGrid の item[1](word層)を解析...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 書きだすファイルを初期化
filedelete ("C:/sound/CSJsample.TextGrid.txt")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# 持続時間を求める
duration = end_time - begin_time
# 条件判断
if duration >= 0.50
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'i...
endif
endfor
selectObject ("TextGrid CSJsample")
Remove
}}
---結果は以下のようになります(4列目が持続時間)
# 0 7.274 7.274
seNse'H 8.214 8.726 0.512
# 10.991 11.564 0.573
(略)
--複数の条件指定も可能です。0.50[秒]以上に加えて、「"#"以...
#geshi(bash){{
(略)
# 条件判断
if duration >= 0.50 and interval_label$ != "#"
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'i...
endif
(略)
}}
---結果は以下のようになります。
seNse'H 8.214 8.726 0.512
--正規表現で抽出条件を指定することも出来ます。0.40[秒]以...
#geshi(bash){{
(略)
# 条件判断
if duration >= 0.40 and index_regex(interval_label$,...
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'i...
endif
(略)
}}
---index_regexは「第一引数で指定した文字列の中で、第二引...
---「[aeiou]H」は正規表現です(([] は「その中のどれか1文字...
---結果は以下のようになります。
(F eH) 7.274 7.738 0.464
(F eH) 7.738 8.214 0.476
kyoHdoH 11.763 12.174 0.410
--上記の正規表現は、必ず a, e, i, o, u に H が後続する文...
---参考用スクリプト(by [[西川賢哉 様:http://speechcorpus...
#----------------------------------------------
str$ = "kawai'H"
clearinfo
if index_regex(str$,"[aiueo]'?H") <> 0
appendInfoLine: str$
endif
#----------------------------------------------
--その他の文字列操作関数は [[Formulas 5. String functions...
***指定した時間区間の切り出しと解析 [#gc250001]
-C:\sound フォルダに入っている sound1.wav を読み込んで、1...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/sound1.wav")
selectObject ("Sound sound1")
do ("Extract part...", 1.100, 1.600, "rectangular", 1, "n...
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
do ("Save as text file...", "C:/sound/sound1_soundpart.Te...
select all
Remove
}}
//--Extract part... の時間(第一・第二引数)を変数で指定...
--第三引数のRectangularは(おそらく)方形窓で切り出し。(...
-C:\sound フォルダに入っている sound1.wav を読み込んで、...
clearinfo
# ファイルを読み込む
do ("Read from file...", "C:/sound/sound1.wav")
selectObject ("Sound sound1")
# 開始時間・終了時間を得る
start_time = Get start time
end_time = Get end time
# 時間的中心点の時間を得る
center_time = (end_time - start_time) / 2
# フォルマント解析
do ("To Formant (burg)...", 0.01, 5, 5500, 0.02, 50)
# 時間的中心点の第一・第二フォルマントを得る
formant_one = Get value at time: 1, center_time, "Hertz"...
formant_two = Get value at time: 2, center_time, "Hertz"...
# 情報ウインドウに表示する
print 'center_time','formant_one','formant_two''newline$'
# メモリ開放
Remove
selectObject ("Sound sound1")
Remove
--結果は以下のようになります。
0.11665532879818594,630.9603036852504,1192.343426813945
***指定した時間を含むTier要素の抽出 [#lfc3f7c9]
-C:\sound フォルダに入っている &ref(CSJsample.TextGrid); ...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 3.200[秒]の時点を含むword要素のインデックス番号を得る(...
word_index = Get interval at time... 1 3.200
# そのラベルと開始・終了時間を得る(第一引数はitem番号)
word$ = Get label of interval... 1 word_index
begin_time = Get starting point... 1 word_index
end_time = Get end point... 1 word_index
print 'word$''newline$''begin_time''newline$''end_time'
selectObject ("TextGrid CSJsample")
Remove
}}
***TextGridのTier間の照合 [#k5165d07]
-[[TextGridを読み込んで、特定の要素のみを書き出す:http://...
#geshi(bash){{
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# 書きだすファイルを初期化
filedelete ("C:/sound/CSJsample.TextGrid.txt")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# end_time と item[3](break層)の各要素の時間を比較...
break_index = Get nearest index from time... 3 end_t...
# item[3](break層)の break_index 番目の要素のラベ...
boundary$ = Get label of point... 3 break_index
# item[3](break層)の break_index 番目の要素の時間...
boundary_time = Get time of point... 3 break_index
# ファイルに書き出す
fileappend "C:/sound/CSJsample.TextGrid.txt" 'interv...
endfor
selectObject ("TextGrid CSJsample")
Remove
}}
--結果は以下のようになります。
# 7.274 F 7.738
(F eH) 7.738 F 7.738
(F eH) 8.214 F 8.214
---2列目がword層の終了時間、新しく追記された3列目がbrake...
***TextGridの数値の集計(フォルマント) [#ha0d4707]
-[[ここ:http://speechresearch.fiw-web.net/index.php?Praat...
#geshi(bash){{
clearinfo
# ファイルを読み込む
do ("Read from file...", "C:/sound/sound1.TextGrid")
# フォルマント型のTextGridであれば、以下のオブジェクトが...
selectObject ("Formant sound1")
# 第二フォルマントの1.500[秒]時点の値を得る
f_two_point = Get value at time... 2 0.150 Hertz Linear
print 'f_two_point''newline$'
# 第二フォルマントの平均値を得る
f_two_mean = Get mean... 2 0 0 Hertz
print 'f_two_mean''newline$'
# 第二フォルマントの中央値を得る
f_two_median = Get quantile... 2 0 0 Hertz 0.50
print 'f_two_median''newline$'
# 第二フォルマントの最大値を得る
f_two_max = Get maximum... 2 0 0 Hertz Parabolic
print 'f_two_max''newline$'
# 第二フォルマントの最小値を得る
f_two_min = Get minimum... 2 0 0 Hertz Parabolic
print 'f_two_min''newline$'
Remove
}}
--各処理の引数の「0 0」に任意の開始時間、終了時間を与える...
--Formant: Get value at time... コマンドは、指定した時間...
--各処理の詳細、およびその他のフォルマント型のオブジェク...
***TextGridの数値の集計(ピッチ) [#k68bbabf]
-[[TextGridの集計(フォルマント):http://speechresearch.f...
--ピッチ型のオブジェクトに対して実行可能な操作は、公式マ...
***データテーブルを作る [#oaa55a09]
-Praat では New > Tables > Create Table with column names...
--[[TextGridを読み込んで、特定の要素のみを書き出す:http:/...
#geshi(bash){{
# テーブルを作る
word_table = Create Table with column names... word_table...
# ファイルを読み込む
do ("Read from file...", "C:/sound/CSJsample.TextGrid")
selectObject ("TextGrid CSJsample")
# item[1](word層)の intervals の総数(word要素の総数)...
number_of_intervals = Get number of intervals... 1
# intervals(各要素)を順番に処理していく
for i from 1 to number_of_intervals
selectObject ("TextGrid CSJsample")
# item[1] の intervals[i] の text を得る
interval_label$ = Get label of interval... 1 'i'
# item[1] の intervals[i] の xmin を得る
begin_time = Get starting point... 1 'i'
# item[1] の intervals[i] の xmax を得る
end_time = Get end point... 1 'i'
# テーブルに各要素を代入
selectObject ("Table word_table")
Set string value... i table_word_label 'interval_lab...
Set string value... i table_begin_time 'begin_time'
Set string value... i table_end_time 'end_time'
# テーブルの行数を増やす
Append row
endfor
selectObject ("TextGrid CSJsample")
Remove
# テーブルをタブ区切りで保存
selectObject ("Table word_table")
do ("Save as tab-separated file...", "C:/sound/word_table...
Remove
}}
---「Create Table with column names...」の第一引数はテー...
---実行すると Praat Objectsウインドウに Tableオブジェクト...
#ref(Praat_tablesample01.png,,70%);
---また、タブ区切りのテキストファイル word_table.txt が保...
***オブジェクトの削除(Remove) [#xf9054c6]
-【注】以下はオブジェクト名を使ったやり方です。''「音声コ...
-大量のwavファイルを順番に処理するときなどは、オブジェク...
-Removeコマンドを使います。
--例:C:\sound フォルダに入っている全ての .wav 形式ファイ...
#geshi(bash){{
#フォルダのパス
directory$ = "C:/sound/"
#フォルダ内の全ての.wav形式のファイル名を取得
Create Strings as file list... list 'directory$'/*.wav
number_files = Get number of strings
#各ファイルを順番に処理
for i from 1 to number_files
#今回のファイルの名前を取得
selectObject ("Strings list")
current_token$ = Get string... 'i'
#.wavファイルを読み込む
do ("Read from file...", "'directory$'/'current_token...
#このオブジェクトの名前を得ておく
info$ = Info
objectname$ = extractLine$(info$, "Object name: ")
#サンプリング周波数を変換する
Resample... 16000 50
do ("Write to WAV file...", "'directory$'/'objectname...
print wav: 'directory$'/'objectname$'_16000.wav'newli...
#サンプリング周波数変換後のオブジェクトを削除する
Remove
#サンプリング周波数変換前のオブジェクトを削除する
selectObject ("Sound 'objectname$'")
Remove
endfor
selectObject ("Strings list")
Remove
}}
---オブジェクトが作られた直後であれば、そのオブジェクトが...
---listオブジェクトであれば、オブジェクト名は「Strings li...
--Soundオブジェクト名は、「Sound (拡張子を除いたそのファ...
**音素自動ラベリング(音声認識)との連携 [#l9746598]
-音素自動ラベリングの結果をPraat標準の形式に変換してPraat...
-Julius((Copyright (c) 1991-2009 京都大学 河原研究室, Cop...
--[[JuliusとJulian/音素自動ラベリング:http://speechresear...
-HTK の HVite コマンドによる方法
--[[HTKによる音響モデル構築/自動ラベリング:http://speechr...
-'''[[西川先生作成の音素ラベリング自動化ツール:http://sho...
**Tips [#t10149ad]
***メモリーオーバーエラーが出て解析が止まってしまったとき...
-[[オブジェクトの削除:http://speechresearch.fiw-web.net/4...
-仮想メモリの上限を上げる。常駐ソフトを停止させる。エクス...
-メモリ容量の大きいPCを使うのが一番手っ取り早いようです。
-重たい解析(リサンプリングや、短い窓長でフォルマント解析...
--[[指定した時間区間の切り出しと解析:http://speechresearc...
***半角括弧「(」「)」をファイル名に含む場合 [#q201b90d]
-半角括弧のファイル名は、Praatオブジェクトに取り込まれた...
-Praatスクリプトでオブジェクト名を指定する場合、例えば以...
#geshi(bash){{
(略)
#拡張子を除去したファイル名(オブジェクト名)を得る
objname$ = current_token$ - ".wav"
#ファイル名の半角括弧はオブジェクト名では「_」に置換される
objname$ = replace$ (objname$, "(", "_", 0)
objname$ = replace$ (objname$, ")", "_", 0)
(略)
}}
***コマンドラインで Praat を実行したいとき [#g6beae09]
-[[sendpraat.exe:http://www.fon.hum.uva.nl/praat/sendpraa...
-sendpraatの引数としてPraatスクリプトを指定すればOK.
***録音とラベリング [#y401615e]
-北原先生の [[Praat Tutorial:http://www.f.waseda.jp/kitah...
***動画ラベリングツールとの連携 [#mec9d57f]
-[[ELAN:http://speechresearch.fiw-web.net/16.html]] がPra...
***TSV/CSVデータファイルから .TextGrid ファイルを生成する...
-参考:[[Praatの音声アノテーション(.TextGrid)を自動生成...
-- [[TextGridConverter:https://github.com/Syuparn/TextGri...
**リンク [#fdd7fe63]
-[[Paul Boersma's writings on the Praat program:http://ww...
-[[Praat Tutorial:http://www.f.waseda.jp/kitahara/Notes/p...
-[[Akira Utsugi's web site Praat入門:https://sites.google...
--[[マルソリ・ラボ 研究関連メモ(Praat):http://utsakr.bl...
-[[PraatLauncher:http://language.world.coocan.jp/scripts/...
ページ名:
既存のページ名で編集する