0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Colabで音声信号処理をする入り口

Last updated at Posted at 2021-05-30
import IPython
import librosa
import librosa.display
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()



# pydubはcolabに入っていない
# loadで読み込み、sr=Noneを明示的に設定すると、元のサンプリングが保持される
# y, sr = librosa.load('menuettm.mp3', sr=None)
y, sr = librosa.load(librosa.ex('trumpet'))

# 波形を表示
librosa.display.waveplot(y, sr=sr)
plt.show()

# メルスペクトログラム(人間の聴覚に適したスペクトログラム)
S = librosa.feature.melspectrogram(y=y, sr=sr)
S_dB = librosa.power_to_db(S, ref=np.max)
librosa.display.specshow(S_dB, sr=sr, x_axis='time', y_axis='mel')
plt.colorbar()


# 音声を流す
IPython.display.Audio(y, rate=sr)

image.png

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?