• Stars
    star
    113
  • Rank 308,369 (Top 7 %)
  • Language
    Python
  • Created about 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple example for use speech recognition baidu api with python.

python语音识别项目


python3.5 语音识别 百度语音API

Build Status Coverage Status Code Climate

项目简介

本项目使用 python3.5,包管理使用 pip3.5,用 pyaudio 录音, numpy 计算, scipy 滤波, pylab 绘制波形与频谱。

项目环境

推介在与项目根目录同级目录内通过 virtualenv 建立 python 虚拟环境:

virtualenv --no-site-packages venv

第一次会自动安装一些虚拟环境文件,安装完后再激活虚拟环境,
Windows 环境下使用:

venv\Scripts\activate

Linux 环境下使用:

source venv/bin/activate

cd 回到项目根目录中,项目依赖都写在 requirements.txt 中,

Windows

在我的 Win 10 环境中 numpy 1.11.1+mklscipy 0.18.1 两个包都不能通过 pip 安装成功,
因此我去加利福尼亚大学镜像源下载了 numpy scipy 这两个包的 win 下支持的 .whl 文件并先通过 pip 安装:

pip install numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whl
pip install scipy-0.18.1-cp35-cp35m-win_amd64.whl

然后再用 pip 安装 requirements.txt 的依赖:

pip install -r requirements.txt

全部通过安装后才算是建立好项目环境了

Ubuntu 14.04 trusty

由于项目使用 Travis-CI 的系统是 ubuntu 14.04 trusty,
因此 ubuntu 下的安装依赖可以参考 .travis.yml 中使用 travis_env_init.sh 进行安装,
在上面 virtualenv 环境中,项目根目录下,使用以下命令执行安装:

sudo source travis_env_init.sh

或者

sudo ./travis_env_init.sh

预安装完成后,再 pip install -r requirements.txt 安装剩下的依赖。 安装脚本本来是针对 Travis 的环境,并非写的兼容的,
如有其他包安装失败,请手动排查。

配置说明

本项目使用 百度语音识别 API
所以请先去 百度语音开放平台 建立工程,申请 API key、 Secret key,
具体申请过程可参见 玩转百度语音识别,就是这么简单 这篇文章。
./BaiduSpeech 目录下的 BaiduOAuthSample.ini 是配置示例文件,先复制 BaiduOAuthSample.iniBaiduOAuth.ini
再按照文件示例中对应位置填写自己的 api_key secret_key,键值间等号左右各空一格,值项无需引号,
若已有 token 可填写 access_token 项。

使用说明

根目录中的 SpeechRecognise.py 为语音识别启动文件

python3.5 SpeechRecognise.py

启动后对准话筒说话,控制台将输出识别结果。(距离话筒的远近与话筒灵敏度相关)

结构说明

根目录中的 SpeechRecognise.py 为语音识别启动文件,
WaveOperate 包中封装了一些对声卡的常用操作,如:
录音、播放、保存文件、读取文件、绘制声波、绘制频谱、声音滤波 等操作。
BaiduSpeech 包中为对 Baidu API 调用的封装,其中 BaiduOAuth.ini 为百度 API key 配置文件。
UnitTest 包中为各模块的单元测试文件, 在项目根目录下执行命令 python3.5 -m nose -vs --with-coverage 将自动执行单元测试并输出结果和覆盖率。

项目思路

本项目语音识别的思路是:

  1. 麦克风阵列录音产生音频流
  2. 语音增强
    2.1 音频流实时带通滤波,除去低音和高音
    2.2 通过过零率 ZSR 和短时能量 Ep 进行 VAD 语音端点检测
    2.3 切分判断有人声说话的音频部分
  3. 去混响(回声)
    3.1 双麦技术
    3.2 NLMS 自适应滤波
  4. 背景噪音消除
    4.1 双麦背景消除
  5. 波束形成
    5.1 声源信号分离
  6. 语音提取
    6.1 声纹识别
  7. 语音识别
    7.1 百度语音 API
    7.2 Google 语音 API
    7.3 讯飞语音 API
  8. 语义分析
    8.1 Hanlp 句法词法依存分析
    8.2 Boson 句法词法依存分析
  9. 参数化指令
    9.1 Cortana XML 指令解析

当然,以上并没有完全实现。。。

实现的项目:

  • pyaudio录音
  • 音频流实时带通滤波
  • 短时能量 Ep 判断
  • 切分判断有人声说话的音频部分
  • 语音识别-百度语音 API
  • Hanlp 依存分析
  • Boson 依存分析

More Repositories

1

react-dev-inspector

jump to local IDE code directly from browser React component by just a simple click
TypeScript
1,149
star
2

kugimiya-rainbow-fart

傲 娇 钉 宫,鞭 写 鞭 骂 - 钉宫理惠 vscode-rainbow-fart 扩展语音包
JavaScript
814
star
3

hexo-theme-Wikitten

A theme of Hexo for personal wiki which seems like Wikitten style.
JavaScript
677
star
4

jovial

Jovial - A lovely zsh theme with responsive-design, it's pretty fast, keep simple but useful
Shell
446
star
5

zsh-history-enquirer

plugin for zsh history search, enhance interaction
TypeScript
81
star
6

STM32-Contiki_Sensor_Smart_Home

Smart home drivers with contiki system | 2016TI杯四川区电设省赛一等奖
C
50
star
7

hexo-directory-category

Automatically add category to Hexo article according to the article file directory.
JavaScript
40
star
8

wiki-site

My personal knowledge management site.
CSS
37
star
9

STM32-W5500_TCP_Client

STM32F103 control W5500 as TCP client connect to TCP server.
C
23
star
10

init-macOS-dev

init my macOS development environment
Shell
21
star
11

slides

Some personal slides
CSS
15
star
12

TianVimrc

轻量级 vim 自使用配置,有一些符合我习惯的改键和增加快捷键等;
Vim Script
11
star
13

zthxxx.github.io

blog via vuepress
Vue
7
star
14

tweetopo

A simple spider for Twitter interpersonal topology.
Python
6
star
15

midk

Mapping MIDI keypress to PC keyboard, that you can work or code with your MIDI kerboard 🎉
TypeScript
5
star
16

prinalysis

print document with smart anlyze in cloud, printer & analysis, it's prinalysis.
Vue
4
star
17

LingoCaster

自用的一款在 Raycast 上完美复刻 Alfred 版 YoudaoTranslator 丝滑体验的查词翻译插件
TypeScript
4
star
18

archived-legacy-blog

This blog to record of life.
HTML
3
star
19

leetsolve

simple & light testing frame for LeetCode solutions with JavaScript
JavaScript
3
star
20

tsconfig

zthxxx's base tsconfig
3
star
21

STM32-FingerprintEntranceGuard

STM32-FingerprintEntranceGuard
C
3
star
22

dont-care-log

make git stage ignore specific log code line
JavaScript
2
star
23

zthxxx

profile for github.com/zthxxx
2
star
24

python-OpinionMonitoring

python for monitor public opinion
Python
2
star
25

CSharp-FingerprintEntranceGuardwindowsTerminal

CSharp Fingerprint Entrance Guard windows Terminal
C#
2
star
26

python-flask-IoT_Sensor_Web

A web to IoT Sensor with flask frame.
JavaScript
2
star
27

pikapika-tab

A pure New-Tab extension that could only customize backgrounds.
TypeScript
2
star
28

vectorial

[WIP] simple demo for a real-time collaborative Vector Path editing library
TypeScript
2
star
29

TunnelAssist

A SPA for assist calculate tube model
JavaScript
1
star
30

sniputils

🚀 snippet utils with powerful influence
Python
1
star
31

SSlaunch

run BBR, install shadowsocks, launch ssserver and print the config QRCode.
Shell
1
star
32

getrusage.js

system function getrusage() precompiled and binding for Nodejs
JavaScript
1
star
33

chicken-dinner-daily

daily punch for chicken dinner everyday
Python
1
star