Skip to content

Instantly share code, notes, and snippets.

@TakanoHori
Created November 5, 2022 12:14
Show Gist options
  • Save TakanoHori/626904024b2fc34ae13ea449b9988211 to your computer and use it in GitHub Desktop.
Save TakanoHori/626904024b2fc34ae13ea449b9988211 to your computer and use it in GitHub Desktop.
import parselmouth
import pandas as pd
# 音声を読み込む
snd = parselmouth.Sound("*.wav")
# フォルマント分析
formants_burg = snd.to_formant_burg(max_number_of_formants=5.0, maximum_formant=5500.0, window_length=0.025, pre_emphasis_from=50.0)
# 各時刻における第1~第4フォルマントを取得する
# pandasを使って成形する
formants = []
for t in formants_burg.xs():
tmp = []
for num in range(1,5):
tmp.append(formants_burg.get_value_at_time(formant_number=num,time=t,unit='HERTZ'))
formants.append(tmp)
df = pd.DataFrame(formants, columns=[1,2,3,4], index=formants_burg.xs())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment