Hello everybody, the game play-by-play video: tv: fun: smile: Now that we have become cold Be careful on the physical condition management: tea: Pazudora, Monsuto, Gacha: gem: Did you draw? How was Pazudora's God Festival? Green Odin is out: +1:
By the way, from O'Reilly [Practical Machine Learning System (Amazon)](http://www.amazon.co.jp/gp/product/4873116988/ref=as_li_tf_tl?ie=UTF8&camp=247&creative=1211&creativeASIN=4873116988&linkCode=as2&tag=scleen- 22) has been published. Since I was able to borrow it, I will write something that will be helpful when starting machine learning by referring to "Music genre classification": musical_note: in this chapter 9: smile: For beginners: exclamation: More difficult Leave the theory and application to great people
Let the computer recognize something! ⇒ For ⇒ For the time being, let's grasp the characteristics of the target! If the features are close, they are similar! ⇒ For ⇒ We will analyze and analyze and make the target numerical!
It's strange Japanese to make the target a number: sweat_drops: It seems to say in difficult words such as "extract features".
Chapter 9 of Book: Practical Machine Learning System I will take up the music genre classification in. But there are only 20 pages. You can't understand everything on page 20, so it's coming little by little with the feeling of increasing the volume.
** If you do not have peripheral knowledge, it will not work due to an error, so I will supplement it **
Music genres are categorized in the book. I'm not interested in the music genre, so I'll try it with a live video of the game on YouTube. I don't know if it will work: scream:
I'm sorry to all MAC users: sob:
--ffmpeg (used to separate audio from video) --Videos used for analysis: Please prepare videos. * URLs for downloaders, etc. are often contaminated with adware or viruses, so I will not post them (laughs). Look for something safe: mag: --python + scipy or You can download it from here ⇒ python2.7 has been installed (as of November 2014) )
--windows7 (64bit)
--Various operations using python (such as how to use Python Interpreter) --General programming knowledge (more is better) --Knowledge about audio file format (a little) --Audacity Very convenient free software to play with audio files
It ’s the turn of ffmpeg, which everyone loves.
ffmpeg -i input.mp4 -map 0:1 test.wav
Extract the audio with wav like this.
** A module called scipy used for analysis can directly read wav format files, so be sure to prepare in wav format. ** **
I think mp3, aac are probably not good
Launch Python Interpreter from the Start menu.
>>>
The prompt looks like this.
>>> import os
>>> os.getcwd()
>>> os.chdir("/work/tmp")
I will feel like it is introduced in the book
import scipy
from matplotlib.pyplot import specgram
sample_rate, X = scipy.io.wavfile.read("test.wav")
print sample_rate, X.shape
specgram(X, Fs=sample_rate, xextent=(0,30))
↑ is a sample that appears in the book, but if I did this as it was, an error occurred.
AttributeError: 'module' object has no attribute 'io'
Or something like that. I will import what I need.
from scipy import io
from scipy.io import wavfile
After doing this, again
specgram(X, Fs=sample_rate, xextent=(0,30))
Then the numbers are messed up: + 1: It worked. However, you will surely think here, "It's not a graph! You can't make a graph even if you do as I wrote in the book: book :!"
Yes, I can't.
import matplotlib.pyplot as plt
pxx, freq, bing, t = plt.specgram(X, Fs=sample_rate, xextent=(0,30))
plt.show()
If you do like this, a new window will open and you will see a graph.
pxx, freq, bing, t = plt.specgram(X, Fs=sample_rate, xextent=(0,30))
An error may occur when executing ↑
The wav file you are using may be too large. Cut with ffmpeg: scissors :. Audacity: sound: You can use it. Audacity may be easier because it has a GUI.
ffmpeg -ss 0 -i test.wav -t 30 -c:a copy short.wav
Let's cut it in the first 30 seconds like this. After that,
sample_rate, X = scipy.io.wavfile.read("short.wav")
pxx, freq, bing, t = plt.specgram(X, Fs=sample_rate, xextent=(0,30))
plt.show()
Did it work?
There is a possibility that the helper will give an error. If the wav file you are using is stereo, this code will not work, so only the left ear will be extracted. You can do it with ffmpeg, but you can also do it with Audacity.
ffmpeg -i short.wav -map_channel 0.0.0 left.wav
Since then
sample_rate, X = scipy.io.wavfile.read("left.wav")
pxx, freq, bing, t = plt.specgram(X, Fs=sample_rate, xextent=(0,30))
plt.show()
You should see the graph.
For those who are too niche to achieve 1000 Pelica: cry:
Recommended Posts