スペクトログラムは,周波数と時間を,縦横の軸とするグラフ.強度を色や明るさで表すことが多い.
【関連する外部ページ】
Windows での Git のインストール: 別ページ »で説明
【関連する外部ページ】
Git の公式ページ: https://git-scm.com/
Windows での Python 3.10,関連パッケージ,Python 開発環境のインストール: 別ページ »で説明
【サイト内の関連ページ】
Python のまとめ: 別ページ »にまとめ
【関連する外部ページ】
Python の公式ページ: https://www.python.org/
コマンドプロンプトを管理者として実行: 別ページ »で説明
pip install -U praat-parselmouth
コマンドプロンプトを管理者として実行: 別ページ »で説明
cd %HOMEPATH% rmdir /s /q Parselmouth git clone --recursive https://github.com/YannickJadoul/Parselmouth
pip install -U numpy matplotlib seaborn
公式ページに記載のプログラムを使用
次のコマンドを実行
cd %HOMEPATH% cd parselmouth jupyter qtconsole
次の Python プログラムを実行する.Matplotlib を使うので,Jupyter QtConsole や Jupyter ノートブック (Jupyter Notebook) の利用が便利である.
import parselmouth import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set() # Use seaborn's default style to make attractive graphs # Plot nice figures using Python's "standard" matplotlib library snd = parselmouth.Sound("docs/examples/audio/the_north_wind_and_the_sun.wav") plt.figure() plt.plot(snd.xs(), snd.values.T) plt.xlim([snd.xmin, snd.xmax]) plt.xlabel("time [s]") plt.ylabel("amplitude") plt.show() # or plt.savefig("sound.png"), or plt.savefig("sound.pdf")
公式ページに記載のプログラムを使用
次のコマンドを実行
cd %HOMEPATH% cd parselmouth jupyter qtconsole
次の Python プログラムを実行する.Matplotlib を使うので,Jupyter QtConsole や Jupyter ノートブック (Jupyter Notebook) の利用が便利である.
import parselmouth import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set() # Use seaborn's default style to make attractive graphs def draw_spectrogram(spectrogram, dynamic_range=70): X, Y = spectrogram.x_grid(), spectrogram.y_grid() sg_db = 10 * np.log10(spectrogram.values) plt.pcolormesh(X, Y, sg_db, vmin=sg_db.max() - dynamic_range, cmap='afmhot') plt.ylim([spectrogram.ymin, spectrogram.ymax]) plt.xlabel("time [s]") plt.ylabel("frequency [Hz]") def draw_intensity(intensity): plt.plot(intensity.xs(), intensity.values.T, linewidth=3, color='w') plt.plot(intensity.xs(), intensity.values.T, linewidth=1) plt.grid(False) plt.ylim(0) plt.ylabel("intensity [dB]") # Plot nice figures using Python's "standard" matplotlib library snd = parselmouth.Sound("docs/examples/audio/the_north_wind_and_the_sun.wav") intensity = snd.to_intensity() spectrogram = snd.to_spectrogram() plt.figure() draw_spectrogram(spectrogram) plt.twinx() draw_intensity(intensity) plt.xlim([snd.xmin, snd.xmax]) plt.show() # or plt.savefig("spectrogram.pdf")