99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
首頁(yè)大數(shù)據(jù)時(shí)代關(guān)于python語音識(shí)別,那還需要掌握這些內(nèi)容
關(guān)于python語音識(shí)別,那還需要掌握這些內(nèi)容
2020-07-22
收藏

我們都知道python是一款功能強(qiáng)大的數(shù)據(jù)分析工具,而且使用起來相對(duì)簡(jiǎn)單,被廣泛應(yīng)用于數(shù)據(jù)分析,web開發(fā),人工智能等很多領(lǐng)域。語音識(shí)別,也叫作自動(dòng)語音識(shí)別,其是以計(jì)算機(jī)自動(dòng)將人類的語音內(nèi)容轉(zhuǎn)換為相應(yīng)文字為目標(biāo)。語音識(shí)別的應(yīng)用范圍,包括、簡(jiǎn)單的聽寫數(shù)據(jù)錄入,語音撥號(hào)、語音導(dǎo)航、室內(nèi)設(shè)備控制、語音文檔檢索等等。當(dāng)語言識(shí)別遇上python,其實(shí)現(xiàn)將會(huì)變得更簡(jiǎn)單,快捷。今天小編與大家分享的就是python語音識(shí)別的一些基礎(chǔ)知識(shí),希望對(duì)大家有所幫助。

一、python語音識(shí)別原理

語音識(shí)別的首要任務(wù)是語音,通常通過麥克風(fēng),語音就能夠從物理聲音轉(zhuǎn)換為電信號(hào),之后再被轉(zhuǎn)換為數(shù)據(jù)。語音一旦被數(shù)字化,就能夠適用若干模型,最終轉(zhuǎn)換為文本。

目前現(xiàn)代大多數(shù)語音識(shí)別系統(tǒng),都是基于隱馬爾可夫模型(HMM)。這一模型的工作原理為:語音信號(hào)在極短的時(shí)間尺度上,例如10 毫秒,能夠被近似為靜止過程,也就是一個(gè)統(tǒng)計(jì)特性不隨時(shí)間變化的過程。而python語音識(shí)別技術(shù), 一些服務(wù)能夠通過 API 在線使用,并且大部分都提供了 Python SDK。

二、選擇python 語音識(shí)別包

apiai

google-cloud-speech

pocketsphinx

SpeechRcognition

watson-developer-cloud

wit

其中, SpeechRcognition為最便捷的一種。

因?yàn)檎Z音識(shí)別首先需要輸入音頻,而 SpeechRecognition 檢索音頻輸入是極為簡(jiǎn)便快捷的,我們并不需要構(gòu)建訪問麥克風(fēng),也不需要從頭開始處理音頻文件的腳,SpeechRecognition 僅僅幾分鐘就能自動(dòng)完成檢索并運(yùn)行。

SpeechRecognition 庫(kù)能夠滿足幾種主流語音 API ,靈活性非常高。例如: Google Web Speech API 支持硬編碼到 SpeechRecognition 庫(kù)中的默認(rèn) API 密鑰,不需要注冊(cè)就能直接使用。因此,SpeechRecognition 由于具有靈活性和易用性的優(yōu)點(diǎn),成為編寫 Python 程序的最佳選擇。

三、python 語音識(shí)別

import numpy as np
import scipy.io.wavfile as wf
import python_speech_features as sf
import hmmlearn.hmm as hl

# 提取樣本信息
train_x,train_y = [],[]
mfccs = np.array([])
for sound_files in files_list:
    for sound_file in sound_files:
        sample_rate,sigs = wf.read(sound_file)
        mfcc = sf.mfcc(sigs,sample_rate)
        # 將mfcc矩陣添加到mfccs中
        if len(mfccs) == 0:
            mfccs == mfcc
        else:
            mfccs = np.append(mfccs,mfcc)
    # 將mfccs矩陣列表添加到訓(xùn)練集中  
    train_x.append(mfccs)
# 最終的train_x len(sound_files)個(gè)特征的矩陣
# train_y存的是特征標(biāo)簽,比如:apple,banana,pear

# 構(gòu)建并訓(xùn)練隱馬模型
models = {}
for mfccs,label in zip(train_x,train_y):
    model = hl.GaussianHMM(
        n_components = 4, covariance_type = 'diag',
        n_iter = 1000
    )
    models[label] = model.fit(mfccs)

# 同樣方法獲取測(cè)試集數(shù)據(jù)
# 測(cè)試
pred_y = []
for mfccs in test_x: 
    # 驗(yàn)證每個(gè)模型對(duì)當(dāng)前mfcc的匹配度得分
    best_score, best_label = None, None
    for label, model in models.items():
        score = model.score(mfccs)
        if (best_score is None) or (best_score < score):
            best_score = score
            best_label = label
    pred_y.append(best_label)

print(test_y)
print(pred_y)

數(shù)據(jù)分析咨詢請(qǐng)掃描二維碼

若不方便掃碼,搜微信號(hào):CDAshujufenxi

數(shù)據(jù)分析師資訊
更多

OK
客服在線
立即咨詢
客服在線
立即咨詢
') } function initGt() { var handler = function (captchaObj) { captchaObj.appendTo('#captcha'); captchaObj.onReady(function () { $("#wait").hide(); }).onSuccess(function(){ $('.getcheckcode').removeClass('dis'); $('.getcheckcode').trigger('click'); }); window.captchaObj = captchaObj; }; $('#captcha').show(); $.ajax({ url: "/login/gtstart?t=" + (new Date()).getTime(), // 加隨機(jī)數(shù)防止緩存 type: "get", dataType: "json", success: function (data) { $('#text').hide(); $('#wait').show(); // 調(diào)用 initGeetest 進(jìn)行初始化 // 參數(shù)1:配置參數(shù) // 參數(shù)2:回調(diào),回調(diào)的第一個(gè)參數(shù)驗(yàn)證碼對(duì)象,之后可以使用它調(diào)用相應(yīng)的接口 initGeetest({ // 以下 4 個(gè)配置參數(shù)為必須,不能缺少 gt: data.gt, challenge: data.challenge, offline: !data.success, // 表示用戶后臺(tái)檢測(cè)極驗(yàn)服務(wù)器是否宕機(jī) new_captcha: data.new_captcha, // 用于宕機(jī)時(shí)表示是新驗(yàn)證碼的宕機(jī) product: "float", // 產(chǎn)品形式,包括:float,popup width: "280px", https: true // 更多配置參數(shù)說明請(qǐng)參見:http://docs.geetest.com/install/client/web-front/ }, handler); } }); } function codeCutdown() { if(_wait == 0){ //倒計(jì)時(shí)完成 $(".getcheckcode").removeClass('dis').html("重新獲取"); }else{ $(".getcheckcode").addClass('dis').html("重新獲取("+_wait+"s)"); _wait--; setTimeout(function () { codeCutdown(); },1000); } } function inputValidate(ele,telInput) { var oInput = ele; var inputVal = oInput.val(); var oType = ele.attr('data-type'); var oEtag = $('#etag').val(); var oErr = oInput.closest('.form_box').next('.err_txt'); var empTxt = '請(qǐng)輸入'+oInput.attr('placeholder')+'!'; var errTxt = '請(qǐng)輸入正確的'+oInput.attr('placeholder')+'!'; var pattern; if(inputVal==""){ if(!telInput){ errFun(oErr,empTxt); } return false; }else { switch (oType){ case 'login_mobile': pattern = /^1[3456789]\d{9}$/; if(inputVal.length==11) { $.ajax({ url: '/login/checkmobile', type: "post", dataType: "json", data: { mobile: inputVal, etag: oEtag, page_ur: window.location.href, page_referer: document.referrer }, success: function (data) { } }); } break; case 'login_yzm': pattern = /^\d{6}$/; break; } if(oType=='login_mobile'){ } if(!!validateFun(pattern,inputVal)){ errFun(oErr,'') if(telInput){ $('.getcheckcode').removeClass('dis'); } }else { if(!telInput) { errFun(oErr, errTxt); }else { $('.getcheckcode').addClass('dis'); } return false; } } return true; } function errFun(obj,msg) { obj.html(msg); if(msg==''){ $('.login_submit').removeClass('dis'); }else { $('.login_submit').addClass('dis'); } } function validateFun(pat,val) { return pat.test(val); }