Parselmouthで音声処理をしてみる 2
以前の投稿で, Parselmouthというライブラリについてまとめた. 今回は音声分析の中でも, 基本的なピッチやフォルマントといった内容のコードを確認する.
分析するデータは, 以前作成した「あいうえお」の母音のデータを対象としている.
# ---------------------------------------------------------
# ピッチ(基本周波数 $F_0$)の抽出
# ---------------------------------------------------------
pitch = snd.to_pitch()
# 0.25秒付近(「あ」の真ん中あたり)のピッチを取得
f0_val = pitch.get_value_at_time(0.25)
print(f"2. [ピッチ] 0.25s地点: {f0_val:.2f} Hz")
# ---------------------------------------------------------
# フォルマント($F_1, F_2$)の抽出
# ---------------------------------------------------------
formant = snd.to_formant_burg()
# 各母音の代表地点でF1, F2を抽出してみる(0.25s=あ, 0.85s=い, 1.45s=う ...)
times = [0.25, 0.85, 1.45, 2.05, 2.65]
vowels = ["あ", "い", "う", "え", "お"]
print("3. [フォルマント解析結果]")
for v, t in zip(vowels, times):
f1 = formant.get_value_at_time(1, t)
f2 = formant.get_value_at_time(2, t)
print(f" 母音 {v}: F1={f1:>6.1f} Hz, F2={f2:>6.1f} Hz")
参考文献
- Jadoul, Y., Thompson, B., & de Boer, B. (2018). Introducing Parselmouth: A Python interface to Praat. Journal of Phonetics, 71, 1-15. https://doi.org/10.1016/j.wocn.2018.07.001
- Boersma, P., & Weenink, D. (2021). Praat: doing phonetics by computer Computer program. Version 6.1.38, retrieved 2 January 2021 from http://www.praat.org/