1
1

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 1 year has passed since last update.

Pythonでの音声信号処理 (1) ファイルの読み込み

Last updated at Posted at 2023-01-08

やりたいこと

音声ファイルを読み込むこと

やってみる

音声ファイル(ここではmp3)を読み込んでみる。

p1_1.py
from pydub import AudioSegment

sd = AudioSegment.from_mp3("data.mp3")
print(sd.duration_seconds)
print(sd.frame_rate)
print(sd.channels)

音声信号部分を取り出してみる。

p1_2.py
from pydub import AudioSegment
import numpy as np

sd = AudioSegment.from_mp3("data.mp3")
sr = np.array(sd.get_array_of_samples())

ch1 = sr[::2]
ch2 = sr[1::2]

for i in map(hex, ch1):
    print(i, end=", ")
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?