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

PythonでMIDIをMP3形式またはWAV形式に変換 (Google Colaboratory)

Posted at

まえがき

この記事はPythonをオンラインで実行できる環境「Google Coraboratory」にて、MIDIをMP3形式またはWAV形式に変換して再生するため手順を書いたものです。
以下に書いた手順通りに実行してください。input.midは変換したいMIDIをご自分で用意してください。

①fluidsynthを事前にダウンロード

!apt install fluidsynth
!cp /usr/share/sounds/sf2/FluidR3_GM.sf2 ./font.sf2
!pip install midi2audio

②midi2audioを使ってMIDIを変換

from midi2audio import FluidSynth
# サウンドフォントを指定する
fs = FluidSynth(sound_font='font.sf2')
# 入力するmidiファイルとアウトプットファイル
fs.midi_to_audio('input.mid', 'output.mp3') # またはoutput.wav

③再生

from IPython.display import Audio
Audio('output.mp3')
3
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
3
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?