[PYTHON] I was free, so I made karaoke (1st content and library) [Unfinished]

Introduction

This is the first post. Please forgive me, although there may be some points that cannot be reached. If you have any typographical errors, omissions, questions, suggestions for improvement, etc., please let us know.

Overall content

plans

--Cut vocals --Display a graph showing the pitch (DAM) --Scoring --Guide vocals (add a thin cut vocal)

if possible

--The one with lyrics (I can't find a good API ...) --Video is played (Youtube is difficult in terms of terms of use ... TextAlive embedding?) --Scoring criteria other than pitch such as vibrato and fist (honestly I can't tell the difference)

Contents of this time

Installation of necessary libraries for the time being

Library to use

According to Introduction to Speech Analysis with Python [PyWorld, pyreaper], pyworld seems to work at high speed even if the speech is long. However, if it is too short, it will take time, so I'm thinking of calculating in real time with pyraper. I will compare it later.

For the time being, it seems that it can be realized around here, so I will add it each time I need something.

Installation

conda install -c conda-forge spleeter
conda install pyaudio
conda install pyQt5
conda install Qt

pip install pyworld
pip install pyreaper

Except for spleeter, I entered with conda or pip.

Operation check

pyaoudio If you run the program in this article and you hear a sound, you are successful.

pyworld Introduction to voice analysis with Python [PyWorld, pyreaper] If you put music in the program and get a graph, it's OK. Figure_1.png

pyreaper

import pyreaper
import matplotlib.pyplot as plt
from scipy.io import wavfile

file = "music/spleetertest/test/vocals.wav"
fs, data = wavfile.read(file)
data = data[:int(1e6),0] #If it is too long, it will take time, so cut it appropriately.
data = data.copy(order='C') #If you don't do this you will get an error
pm_times, pm, f0_times, f0, corr = pyreaper.reaper(data, fs)

#graph display
plt.subplot(3,1,1)
plt.plot(pm_times, pm, linewidth=3, color="red", label="Pitch mark")
plt.legend(fontsize=10)

plt.subplot(3,1,2)
plt.plot(f0_times, f0, linewidth=3, color="green", label="F0 contour")
plt.legend(fontsize=10)

plt.subplot(3,1,3)
plt.plot(f0_times, corr, linewidth=3, color="blue", label="Correlations")
plt.legend(fontsize=10)
plt.show()

Figure_2.png It is OK if such a graph appears

spleeter If you run the program in I tried spleeter and no error occurs, it's OK. It seems that mp3 is also okay.

pyQt5 I haven't verified it because it seems to be okay if matplotlib is running for the time being. Next schedule

I wish I could extract only vocal from music and convert it to a pitch graph.

Recommended Posts

I was free, so I made karaoke (1st content and library) [Unfinished]
I was free, so I made karaoke (2nd vocal extraction and pitch estimation)
I made my own Python library