Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to extract Spectrum Music by python

Shulou Source: shulou.com Published: 2022-05-31 10:50:06 10月05日 Update

This article introduces the relevant knowledge of "how to extract spectrum music from python". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Prepare for

Before you begin, make sure that Python and pip are successfully installed on your computer. Oh, if not, please visit this article: hyperdetailed Python installation Guide for installation.

Open Cmd (start-run-CMD) in Windows environment, and open Terminal (command+ space input Terminal) in Apple system environment, ready to start entering commands to install dependencies.

Of course, I recommend that you use the VSCode editor to Copy the code of this article and install the dependency module in the terminal at the bottom of the editor. What a comfortable thing: the best partner of Python programming-VSCode detailed guide.

Enter the following command at the terminal to install the dependent module we need:

Pip install pydubpip install librosa

If you see Successfully installed xxx, the installation is successful.

two。 Spectrum display

With librosa and matplot, we can fully display the entire spectrum in 10 lines of code:

However, this kind of spectrum is the whole piece of music, and it looks very ugly, so we use pydub to cut the spectrum to get better results. Let's break down to a range of 0 to 1 seconds to view the spectrum:

This is fine, but it is still too complicated. in fact, when we show the spectrum, we only need a positive value:

Then we can further zoom in, for example, the spectrum between 0.9 and 1 second:

This is the end of the content of "how to extract Spectrum Music from python". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Spectrum music input success next code content commands guides more modules environment knowledge terminals editors preparation complex practical comfortable ugly Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker Shulou Information MariaDB Microsoft