쥬피터 환경
music21 설치하기 & musescore 설치하기
pip install music21
한가지 이슈가 있었던게
음표를 입력하고 .show 하는 과정에서 에러가 발생했다.
에러 내용은 musecore 경로에러
from music21 import *
# get environment
print(env)
us = environment.UserSettings()
us['musicxmlPath'] = 'C:\\Program Files\\MuseScore 3\\bin\\MuseScore3.exe'
us['musescoreDirectPNGPath'] = 'C:\\Program Files\\MuseScore 3\\bin\\MuseScore3.exe'
us['musicxmlPath']
해당위의 코드로 경로 변경해주면 .show() 가 잘 되는것을 확인할 수 있다.
from music21 import *
f = note.Note("F5")
f.show()
만약 구글 코랩 환경이라면
from music21 import *
!add-apt-repository ppa:mscore-ubuntu/mscore-stable -y
!apt-get update
!apt-get install musescore
!apt-get install xvfb
!sh -e /etc/init.d/x11-common start
import os
os.putenv('DISPLAY', ':99.0')
!start-stop-daemon --start --pidfile /var/run/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
us = environment.UserSettings()
us['musescoreDirectPNGPath'] = '/usr/bin/mscore'
us['directoryScratch'] = '/tmp'
-> 해당 코드는 꽤 오래 걸림
%%capture
# converts midi files to wav files into order to play them
print('installing fluidsynth...')
!apt-get install fluidsynth > /dev/null
!cp /usr/share/sounds/sf2/FluidR3_GM.sf2 ./font.sf2
from IPython.display import Image, Audio
from music21 import *
def play(x):
filename = x.write('mid')
!fluidsynth -ni font.sf2 $filename -F $filename\.wav -r 16000 > /dev/null
display(Audio(filename + '.wav'))
실행해 주고나면
a = note.Note("C#4")
a.show()
play(a)
플레이도 잘 된다.
참고사이트
'딥러닝 > 소리데이터' 카테고리의 다른 글
[서울대 지능정보 세미나 - 이교구 교수] (3) SVS (Singing Voice Synthesis) : 가창 합성 : 김광석 & 터틀맨 제작 과정 (0) | 2022.10.18 |
---|---|
[서울대 지능정보 세미나 - 이교구 교수] (2) TTS - Text - to - Speech (0) | 2022.10.18 |
[서울대 지능정보 세미나 - 이교구 교수] (1) Sound 컨텐츠 시장의 리스크 & 베토벤 미완성 교향곡 10번 (도이치 텔레콤) (0) | 2022.10.18 |
음성데이터의 기초적인 이해 (MFCC, zero crossing rate) (0) | 2022.04.30 |
음성데이터의 기초적인 이해 (소리의 3요소, 푸리에 변환) (0) | 2022.04.30 |