Let's analyze voice with Python # 1 FFT

Let's do voice analysis with Python

In this article, I will introduce the colors of Python voice analysis step by step.

Pre-conditions

My environment

Required Python library

Import settings


import numpy as np
import matplotlib.pyplot as plt

Chapter 1 ~ Data Preparation ~

I think it is a good flow to read and analyze appropriate voice data, but first, create the data for simplicity. Let's make a sine wave as follows.

Creating a sine wave


def make_wave():
    fs = 48000 #Sampling rate
    f = 10 #frequency
    t = np.linspace(0,1,fs) #48 seconds,000 division
    y = np.sin(2*np.pi*f*t) #Create a sine wave
    return y

I want to reuse it later, so I'll leave it as a function.

Chapter 2 ~ Let's plot ~

Now, let's plot the prepared waves and see the appearance.

plot


    sig = make_wave()
    plt.plot(sig)
    plt.show()

Certainly, a wave that vibrates 10 times has been created. At this time, the horizontal axis is simply the number of data, so there are 0 to 48,000. test.jpg

Chapter 3 ~ Before Analysis ~

The code up to this point can be summarized as follows.

Summary


# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt

def make_wave():
    fs = 48000
    f = 10
    t = np.linspace(0,1,fs)
    y = np.sin(2*np.pi*f*t)
    return y

def main():
    sig = make_wave()
    plt.plot(sig)
    plt.show()

if __name__ == '__main__':
    main()

It's a very simple code, but you can create and check the data with just this. Python is convenient, isn't it? Next time, I will summarize the analysis, so this time it is short, but I'm sorry.

Next Chapter ~ Fast Fourier Transform ~

About fast Fourier transform

Recommended Posts

Let's analyze voice with Python # 1 FFT
Voice analysis with python
Voice analysis with python
Let's run Excel with Python
Let's write python with cinema4d.
Let's build git-cat with Python
Let's make a GUI with python.
Let's play with Excel with Python [Beginner]
Let's do image scraping with Python
Let's make a graph with python! !!
Let's make a shiritori game with Python
Let's create a free group with Python
[Introduction to Python] Let's use foreach with Python
Let's read the RINEX file with Python ①
I want to analyze logs with Python
[Python] Let's make matplotlib compatible with Japanese
Let's do MySQL data manipulation with Python
Let's make a web framework with Python! (1)
Let's get along with Python # 0 (Environment construction)
Let's make a web framework with Python! (2)
[Blender x Python] Let's get started with Blender Python !!
Statistics with python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
Python hand play (let's get started with AtCoder?)
Let's solve simultaneous linear equations with Python sympy!
Let's write FizzBuzz with an error: Python Version
Let's implement English voice dialogue in Python [offline]
[Python3] Let's analyze data using machine learning! (Regression)
Let's control EV3 motors and sensors with Python
Let's replace UWSC with Python (5) Let's make a Robot
Let's do web scraping with Python (stock price)
Let's analyze Covid-19 (Corona) data using Python [For beginners]
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
Sequential search with Python
"Object-oriented" learning with python
Run Python with VBA
Handling yaml with python
Serial communication with python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python