> Hugo tranquilpeak theme

Ajax

1. Intro Ajax can send request without refreshing the webpage. 1.1 Get function clickMe(){ $.ajax({ url: "/user/list", type: "get", data: { name: $("#input1").val(), passwd: $("#input2").val() }, // data: $("#form1").serialize(), dataType: "JSON", success:function(res){ console.log(res.data); } }) } ... <div> <input type="button" value="button" onclick="clickMe();" /> </div> ... Or, we can use JQuery to bind the event of button click. 1.2 Post # views.py from django.shortcuts import render, HttpResponse from django.http import JsonResponse from django.

Continue reading

ORM

1. Install pip install mysqlclient # python<=3.5 pip install pymysql # python>3.5 2. connect # mysite/settings.py ... import pymysql # python>=3.5 pymysql.install_as_MySQLdb() DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'table111', 'USER': 'root', 'PASSWORD': 'Root1234@', 'HOST': 'localhost', 'PORT': 3306, } } ... 3. CRUD # models.py from django.db import models class User(models.Model): name = models.CharField(max_len=32) passwd = models.CharField(max_len=64) age = models.IntegerField() """ create table myapp_user( id bigint auto_increment primary key, name varchar(32), passwd varchar(64), age int ) """ Make sure that we have registered our ‘myapp’ in ‘mysite’ project.

Continue reading

MySQL

1. install brew install mysql mysql.server start mysql_secure_installation Root1234@ See details for installation. If you get an error “The server quit without updating PID file (xxx.lock.pid)” while running the commands above, you can remove the file “/tmp/mysql.sock” and try again. 2. basics mysql -u root -p mysql> show databases; mysql> create database table_name; mysql> use table_name; mysql> create table test( id int auto_increment primary key, name varchar(16) not null, age int default 18, salary decimal(8,2), birth datetime ); mysql> show tables; mysql> insert into test values (1, "zhang san", 23); mysql> insert into test (name, age) values ("li si", 25), ("wang wu", 27); mysql> select * from test where id>3; mysql> delete from test where id=1; mysql> update test set name="abc" where id=2; mysql> drop table test; mysql> drop database table_name; mysql> exit; 3.

Continue reading

Django Quick Start

1. Preparation Firstly, we can install django and create our project as follows. # to install django framework pip install django pip install djangorestframework # create our applications django-admin startproject mysite cd mysite python managy.py startapp myapp To test the project, we can use “runserver” command. python manage.py runserver 2. Models In the file “myapp/models.py”, we can create some models to specify the layout of our database. from django.db import models class User(models.

Continue reading

Formants

1. What is the formant? Formant is a characteristic component of the quality of a speech sound. It is the strongest part on the spectrogram where the botton one is the fundamental frequency F0. Pitch, actually, is a similar concept that reference https://www.zhihu.com/question/24190826/answer/280149476

Continue reading

MFCC

1. Mel Frequency Cepstrum Coefficient $$Mel(f)=2585*log_{10}(1+\frac{f}{700})$$ import numpy as np import matplotlib.pyplot as plt x = np.arange(8001) y = 2595 * np.log10(1+x/700) plt.plot(x, y, color='blue', linewidth=3) plt.xlabel("f", fontsize=17) plt.ylabel("Mel(f)", fontsize=17) plt.xlim(0,x[-1]) plt.ylim(0,y[-1]) plt.savefig('mel_f.png', dpi=500) 2. workflow import numpy as np import scipy.io.wavfile from matplotlib import pyplot as plt from scipy.fftpack import dct # 原始数据,读取前3.5s 的数据 sample_rate, signal = scipy.io.wavfile.read('OSR_us_000_0010_8k.wav') original_signal = signal[0:int(3.5*sample_rate)] signal_num = np.arange(len(signal)) sample_num = np.arange(len(original_signal)) # 绘图 01 plt.

Continue reading

VAE

1. Auto Encoder Before we formally introduce the VAE, let’s first look at the structure of AE. It consists of an Encoder and a Decoder. The input data will be input to the Encoder to get the ‘hidden states’. Then the Decoder will eat these ‘hidden states’ to recover the input which means the output should be as close to the input as possible. Usually, we hope that the dimension of ‘hidden states’ will be less than the input to achieve dimension reduction.

Continue reading

Author's picture

LI WEI

苟日新,日日新,又日新

Not yet

Tokyo