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 3 years have passed since last update.

sox で .raw ファイルを .wav ファイルに変換

Last updated at Posted at 2020-12-06

基本形

例)input.rawoutput.wav にしたい場合

sox -t raw -e signed-integer -b 16 -r 44100 input.raw -t wav output.wav

基本形は↓のように、各ファイルにオプションを付つける形です。出力ファイルのオプションは入力と同じなら省略可能です。

sox [inputオプション] [inputパス] [outputオプション] [outputパス]
オプション 意味
-t, --type ファイルの種類(raw, wav, など)
-e, --encoding エンコーディング (signed-integer, unsigned-integer, floating-point, など)
-b, --bits 量子化ビット数
-r, --rate サンプリング周波数(Hz)

※すべてのオプションは公式ページで確認してください

(メモ) サンプリング周波数を変更

出力オプションを与えることでサンプリング周波数の変換ができます。

例)48kHzのwavファイルを8kHzにダウンサンプリングする

sox -t raw -e signed-integer -b 16 -r 44100 input.raw -t wav -r 8000 output.wav

(メモ) シェルを使って一括で変換

↓のように、rawフォルダの中身を、拡張子を変えつつ wav ファイルに変換したいとします。

.
├ raw
│ ├ 001.raw
│ ├ 002.raw
│ :
└ wav
  ├ 001.wav
  ├ 002.wav
  :

次のようにforを使ってワンライナーで書けます。

for f in $(ls ./raw/*.raw); do sox -t raw -e signed-integer -b 16 -r 44100 "${f}" -t wav "wav/$(basename $f .raw).wav"; done

リンク集

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?