10
7

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.

【音声データ変換】.m4a→.mp3→.wav

Posted at

【音声データ変換】.m4a→.mp3→.wav

目的

windowsのボイスレコーダーで録音した.m4aの音声ファイルを.wavに変換する方法で少し止まったのでメモしておく

解決方法

タイトルの通り、.m4a.mp3.wavのように、mp3を経由して変換したらできた。

コマンド

.m4a.mp3

$ ffmpeg -i input.m4a -ab 256k output.mp3

.mp3.wav

$ sox input.mp3 output.wav channels 1 rate 16k

Pythonとかでまとめてやるなら

import glob, os

# .m4a→.mp3 m4a_dataにある.m4aの音声データをmp3_dataへmp3として保存する
for filename in glob.glob( 'm4a_data/*.m4a' ):
    a = filename[len("m4a_data")+1:][:-4] # ファイル名だけ取り出す ex) m4a_data/hoge.m4a → hoge
    os.system("ffmpeg -i m4a_data/{}.m4a -ab 256k mp3_data/{}.mp3".format(a,a))

for filename in glob.glob( 'mp3_data/*.mp3' ):
    a = filename[len("mp3_data")+1:][:-4] # ファイル名だけ取り出す ex) mp3_data/hoge.mp3 → hoge
    os.system("sox mp3_data/{}.mp3 data_wav/{}.wav channels 1 rate 16k".format(a,a))
10
7
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
10
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?