当前位置: 首页 > news >正文

wordpress 配置安装关键词seo公司

wordpress 配置安装,关键词seo公司,网站选择城市怎么做,中山手机网站建设哪家好1. 首先安装依赖库 pip install playsound # 该库用于播放音频文件 pip install speech_recognition # 该库用于语音识别 pip install PocketSphinx # 语音识别模块中只有sphinx支持离线的,使用该模块需单独安装 pip install pyttsx3 # 该库用于将文本转换为语音播…

1. 首先安装依赖库

pip install playsound # 该库用于播放音频文件
pip install speech_recognition # 该库用于语音识别
pip install PocketSphinx # 语音识别模块中只有sphinx支持离线的,使用该模块需单独安装
pip install pyttsx3 # 该库用于将文本转换为语音播放
pip install comtypes # 该库可以从文本文件中获取输入转换为语音文件

2. 播放音频文件 

from playsound import playsound 
playsound('audio_files\cnhello.mp3')

3. 语音识别

默认只识别英文,如果需要支持中文,需要下载中文模型包,下载地址如下:

CMU Sphinx - Browse /Acoustic and Language Models at SourceForge.net 

下载完解压到sphinx安装路径下:

D:\install\Anaconda\Lib\site-packages\speech_recognition\pocketsphinx-data

 

import speech_recognition as sr
r = sr.Recognizer()
harvard = sr.AudioFile('audio_files\harvard.wav')
with harvard as source:
#     r.adjust_for_ambient_noise(source) # 消除环境背景音audio = r.record(source) # record()函数,将整个音频文件读入AudioData实例
print(type(audio))    
r.recognize_sphinx(audio) 

4. 通过麦克风输入并识别

import speech_recognition as sr
mic = sr.Microphone()
with mic as source:r.adjust_for_ambient_noise(source)audio = r.listen(source)r.recognize_sphinx(audio)

5. 文本转语音播放

import pyttsx3
engine = pyttsx3.init()
engine.say("hello world")
engine.say("你好")
engine.runAndWait()
engine.stop()

6. 文本转语音

# 文本转语音
from comtypes.client import CreateObject
from comtypes.gen import SpeechLibengine = CreateObject("SAPI.SpVoice")
stream = CreateObject('SAPI.SpFileStream')
infile = 'demo.txt'
outfile = 'demo_audio.wav'
stream.open(outfile, SpeechLib.SSFMCreateForWrite)
engine.AudioOutputStream = stream
f = open(infile, 'r', encoding='utf-8')
theText = f.read()
f.close()
engine.speak(theText)
stream.close()

7. 语音转文本(英文识别)

# 语音文件转文本文件
import speech_recognition as sr
r = sr.Recognizer()harvard = sr.AudioFile('demo_audio.wav')
with harvard as source:
#     r.adjust_for_ambient_noise(source)audio = r.record(source)r.recognize_sphinx(audio, language='en-US')

>>'hello everyone my name is bob'

8. 语音转文本(中文识别)

# 语音文件转文本文件
import speech_recognition as sr
r = sr.Recognizer()harvard = sr.AudioFile('demo_audio.wav')
with harvard as source:
#     r.adjust_for_ambient_noise(source)audio = r.record(source)r.recognize_sphinx(audio, language='zh-CN')

 >> '好好 学习 天天 向上'

参考:

python实现语音识别功能

从0开始语音识别

http://www.hkea.cn/news/318639/

相关文章:

  • 九星市场做网站快速将网站seo
  • 长春做网站推广的公司提升神马关键词排名报价
  • 金融网站cms百度网盘客服电话人工服务
  • 美观网站建设物美价廉seo网站优化专员
  • 网站设计应该怎么做推广软文代写
  • 网站建设工作室发展百度收录教程
  • 没有网站 可以做百度口碑吗成都网站制作
  • 医院系统网站建设百度宁波营销中心
  • 网站劫持代码杭州互联网公司排名榜
  • 做网站找哪个部门吸引人的推广标题
  • 网站制作软件名字线做竞价推广代运营公司
  • avada如何做中英文网站沈阳百度推广排名优化
  • 做网站品长沙网络营销公司排名
  • b2b商贸网站环球网最新消息疫情
  • wordpress next主题什么是seo教程
  • 如何规划一个网站快手秒赞秒评网站推广
  • 中国网站开发网站seo需要用到哪些工具
  • 织梦做的网站首页出现空白网页平台做个业务推广
  • 备案做电影网站吗yandx引擎入口
  • 网站双倍浮动百度账号登陆入口
  • 聊城市网站建设网站推广排名
  • 帝国新闻网站模板百度seo推广怎么做
  • 预约做港澳证的网站网站排名在线优化工具
  • 罗湖实惠的网站建设费用成都官网seo厂家
  • 建设部官方网站有哪些优帮云排名优化
  • 天津做网站找谁新东方在线教育平台官网
  • 南宁做网站在哪了日本预测比分
  • 咋样查看网站用什么编程语言做的9个广州seo推广神技
  • 网站链接太多怎么做网站地图谷歌广告
  • 网站关键词更新临汾网络推广