• 大小: 14.45MB
    文件类型: .zip
    金币: 2
    下载: 0 次
    发布日期: 2023-07-31
  • 语言: C/C++
  • 标签:

资源简介

Auto Speaker Recognition main.py the main file for test audio_record.py record audio from micro phone count_days.py count days between two date. 20110805 20160903 mfcc_feature.py extract mfcc feature from wav files SGD.model* the trained model on train set , and the accurate is 70% util.py contains the most useful functions train train data is 75% of all the data test test data is 25% of all the data and has no overlap with train set classification_SGD.py is the main classification function py file , and it used the sklearn's SGD niter was set 10000 could get 70% of accurate. classification_BNB.py this is the sklern naive_bayes BernoulliNB , and it reach to just 56% classification_DT.py this is the sklern tree.DecisionTreeClassifier , and it reach to just 63% classification_GB.py this is the sklern GradientBoostingClassifier, and it reach to the best now of 76% when n_estimators=1000, but it produce too many model components to store. classification_GNB.py this is the sklern naive_bayes GaussianNB, and it reach to just 63% vote_result.py add a vote decsion , every method have the acurrcy number ticiks to vote the final answer. after the vote , we achived 96% at test set. beta1.0

资源截图

代码片段和文件信息

#!usr/bin/env python
# coding=utf-8
import wave
from Tkconstants import LEFT

from Tkinter import Tk

from Tkinter import Button

from Tkinter import Label
from datetime import datetime
from pyaudio import PyAudio paInt16

# define of params
NUM_SAMPLES = 2000
framerate = 8000
channels = 1
sampwidth = 2
# record time
TIME = 10


def save_wave_file(filename data):
    ‘‘‘save the date to the wav file‘‘‘
    wf = wave.open(filename ‘wb‘)
    wf.setnchannels(channels)
    wf.setsampwidth(sampwidth)
    wf.setframerate(framerate)
    wf.writeframes(““.join(data))
    wf.close()
    return 0


def my_button(root label_text button_text button_func):
    ‘‘‘‘‘function of creat label and button‘‘‘
    # label details
    label = Label(root)
    label[‘text‘] = label_text
    label.pack(side=LEFT)
    # label details
    button = Button(root)
    button[‘text‘] = button_text
    button[‘command‘] = button_func
    button.pack(side=LEFT)


def record_wave():
    # open the input of wave
    pa = PyAudio()
    stream = pa.open(format=paInt16 channels=1
                     rate=framerate input=True
                     frames_per_buffer=NUM_SAMPLES)
    save_buffer = []
    count = 0
    while count < TIME * 4:
        # read NUM_SAMPLES sampling data
        string_audio_data = stream.read(NUM_SAMPLES)
        save_buffer.append(string_audio_data)
        count += 1
        print ‘.‘

    filename = datetime.now().strftime(“%Y-%m-%d_%H_%M_%S“) + “.wav“
    save_wave_file(filename save_buffer)
    save_buffer = []
    print filename “saved“
    return 0


def main():
    root = Tk()
    my_button(root “Record a wave“ “clik to record“ record_wave)
    root.mainloop()


if __name__ == “__main__“:
    main()

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-08-31 08:35  python_tutorial_ASR-master\
     文件        1045  2016-08-31 08:35  python_tutorial_ASR-master\.gitignore
     目录           0  2016-08-31 08:35  python_tutorial_ASR-master\.idea\
     文件         159  2016-08-31 08:35  python_tutorial_ASR-master\.idea\encodings.xml
     目录           0  2016-08-31 08:35  python_tutorial_ASR-master\.idea\inspectionProfiles\
     文件         425  2016-08-31 08:35  python_tutorial_ASR-master\.idea\inspectionProfiles\Project_Default.xml
     文件         235  2016-08-31 08:35  python_tutorial_ASR-master\.idea\inspectionProfiles\profiles_settings.xml
     文件         735  2016-08-31 08:35  python_tutorial_ASR-master\.idea\misc.xml
     文件         290  2016-08-31 08:35  python_tutorial_ASR-master\.idea\modules.xml
     文件         568  2016-08-31 08:35  python_tutorial_ASR-master\.idea\python_tutorial_ASR.iml
     文件         180  2016-08-31 08:35  python_tutorial_ASR-master\.idea\vcs.xml
     文件       44571  2016-08-31 08:35  python_tutorial_ASR-master\.idea\workspace.xml
     文件        1327  2016-08-31 08:35  python_tutorial_ASR-master\README.md
     文件        1739  2016-08-31 08:35  python_tutorial_ASR-master\audio_record.py
     文件        2701  2016-08-31 08:35  python_tutorial_ASR-master\classification_BNB.py
     文件        2716  2016-08-31 08:35  python_tutorial_ASR-master\classification_DT.py
     文件        3557  2016-08-31 08:35  python_tutorial_ASR-master\classification_GB.py
     文件        2714  2016-08-31 08:35  python_tutorial_ASR-master\classification_GNB.py
     文件        2809  2016-08-31 08:35  python_tutorial_ASR-master\classification_SGD.py
     文件        2605  2016-08-31 08:35  python_tutorial_ASR-master\count_days.py
     文件        6056  2016-08-31 08:35  python_tutorial_ASR-master\main.py
     文件       14925  2016-08-31 08:35  python_tutorial_ASR-master\mfcc_feature.py
     目录           0  2016-08-31 08:35  python_tutorial_ASR-master\model\
     文件         510  2016-08-31 08:35  python_tutorial_ASR-master\model\BNB.model
     文件         128  2016-08-31 08:35  python_tutorial_ASR-master\model\BNB.model_01.npy
     文件         704  2016-08-31 08:35  python_tutorial_ASR-master\model\BNB.model_02.npy
     文件         704  2016-08-31 08:35  python_tutorial_ASR-master\model\BNB.model_03.npy
     文件         128  2016-08-31 08:35  python_tutorial_ASR-master\model\BNB.model_04.npy
     文件         128  2016-08-31 08:35  python_tutorial_ASR-master\model\BNB.model_05.npy
     文件         811  2016-08-31 08:35  python_tutorial_ASR-master\model\DT.model
     文件          88  2016-08-31 08:35  python_tutorial_ASR-master\model\DT.model_01.npy
............此处省略18301个文件信息

评论

共有 条评论