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

自贸区网站建设建设织梦网站模板

自贸区网站建设,建设织梦网站模板,音乐应用网站模板,wordpress框架文件上传文章目录 理论文本转换为语音使用 pyttsx使用 SAPI使用 SpeechLib 语音转换为文本 代码和效果01使用pyttsx实现文本_语音02使用SAPI实现文本_语音03使用SpeechLib实现文本_语音04使用PocketSphinx实现语音转换文本 理论 语音识别技术#xff0c;也被称为自动语音识别#xf… 文章目录 理论文本转换为语音使用 pyttsx使用 SAPI使用 SpeechLib 语音转换为文本 代码和效果01使用pyttsx实现文本_语音02使用SAPI实现文本_语音03使用SpeechLib实现文本_语音04使用PocketSphinx实现语音转换文本 理论 语音识别技术也被称为自动语音识别目标是以电脑自动将人类的语音内容转换为相 应的文字和文字转换为语音。 文本转换为语音 使用 pyttsx 使用名为 pyttsx 的 python 包你可以将文本转换为语音。直接使用 pip 就可以进行安装 命令如下 pip install pyttsx3【示例】使用 pyttsx 实现文本转换语音 import pyttsx3 as pyttsx enginepyttsx.init() engine.say(你好 pyttsx) engine.runAndWait() 使用 SAPI 在 python 中你也可以使用 SAPI 来做文本到语音的转换。 【示例】使用 SAPI 实现文本转换语音 from win32com.client import Dispatch msg你好 SAPI speaker Dispatch(SAPI.SpVoice) speaker.Speak(msg) del speaker 使用 SpeechLib 使用 SpeechLib可以从文本文件中获取输入再将其转换为语音。先使用 pip 安装 命令如下 pip install comtypes 【示例】使用 SpeechLib 实现文本转换语音 from comtypes.client import CreateObject engineCreateObject(SAPI.SpVoice) streamCreateObject(SAPI.SpFileStream) from comtypes.gen import SpeechLib infiledemo.txt outfiledemo_audio.wav stream.Open(outfile,SpeechLib.SSFMCreateForWrite) engine.AudioOutputStreamstream fopen(infile,r,encodingutf-8) theTextf.read() f.close() engine.speak(theText) stream.close() 语音转换为文本 使用 PocketSphinx PocketSphinx 是一个用于语音转换文本的开源 API。它是一个轻量级的语音识别引擎 尽管在桌面端也能很好地工作它还专门为手机和移动设备做过调优。 首先使用 pip 命令安装所需模块命令如下 pip install PocketSphinx pip install SpeechRecognition 【示例】使用 PocketSphinx 实现语音转换文本 import speech_recognition as sr audio_filedemo_audio.wav rsr.Recognizer() with sr.AudioFile(audio_file) as source: audio r.record(source) try: # print(文本内容,r.recognize_sphinx(audio,languagezh_CN)) print(文本内容,r.recognize_sphinx(audio)) except Exception as e: print(e) 注意 □ 安装完 speech_recognition 之后是不支持中文的需要在 Sphinx 语音识别工具包里 面 下 载 对 应 的 普 通 话 升 学 和 语 言 模 型 。 下 载 地 址 https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Mo dels/ □ 将 下 载 好 的 普 通 话 升 学 和 语 言 模 型 放 到 安 装 speech_recognition 模 块 的 pocketsphinx-data 目录下。 代码和效果 01使用pyttsx实现文本_语音 import pyttsx3 as pyttsx enginepyttsx.init() engine.say(好好学习) engine.runAndWait()复制到vscode或其他运行时需要 pip install pyttsx3 02使用SAPI实现文本_语音 from win32com.client import Dispatch speakerDispatch(SAPI.SpVoice) speaker.Speak(大家好) del speaker03使用SpeechLib实现文本_语音 from comtypes.client import CreateObject from comtypes.gen import SpeechLib engineCreateObject(SAPI.SpVoice) streamCreateObject(SAPI.SpFileStream) infiledemo.txt outfiledemo_audio.wav stream.open(outfile,SpeechLib.SSFMCreateForWrite) engine.AudioOutputStreamstream #读取文本内容 fopen(infile,r,encodingutf-8) theTextf.read() f.close() engine.speak(theText) stream.close()需要将文本放到电脑根目录下 04使用PocketSphinx实现语音转换文本 import speech_recognition as sr audio_filedemo_audio.wav rsr.Recognizer() #打开语音文件 with sr.AudioFile(audio_file) as source:audior.record(source)#将语音转换为文本 # print(文本内容,r.recognize_sphinx(audio)) print(文本内容,r.recognize_sphinx(audio,languagezh-CN))一、安装环境库 ModuleNotFoundError: No module named ‘speech_recognition’ 是pip install speechrecognition 再安装pip install PocketSphinx 二、文件放根目录
http://www.zqtcl.cn/news/309361/

相关文章:

  • 青岛专业制作网站的公司吗百度咨询
  • 自定义网站模块深圳宝安区有什么好玩的地方
  • 如何增加网站的外链微平台网站支持html5实现游戏
  • 平台网站建设网站邯郸seo优化
  • 做网站着用什么软件盐城网站建设电话
  • 自己的网站wordpress自动变化文字
  • 北京制作网站公司哪家好wordpress小工具不显示不出来
  • 如何建设一个新的网站h5网站建设价格
  • 无锡专业做网站的怎么攻击php做的网站
  • 盐城网站建设代理商wordpress定义字体颜色
  • 成都旅游网站建设地址自己做的网站怎么被搜索出来
  • 网站建设免费免代码商城微网站如何做
  • 网站建设域名是什么东莞网络科技营销
  • 法语网站建设高端网站建设 骆
  • vue网站开发注意事项做设计想接外单去哪个网站好
  • 免费模板下载网站推荐苏州seo
  • 徐州市水利工程建设有限公司网站网站建设技术团队有多重要性
  • 合肥佰瑞网站搜索引擎优化步骤
  • 营销型网站建设亏1广西桂林天气预报15天
  • 想做一个网站平台怎么做公司网站建设费用估计
  • 电商网站开发平台pi netwo网页设计文件下载
  • 南平网站设计笔记本怎么建设网站
  • 舆情分析网站免费人工智能培训班收费标准
  • 青岛网站建设 大公司制作相册视频
  • 什么是网站的域名jquery素材网站
  • 课程网站建设ppt模板百度seo推广
  • 网站建设需要用到什么怎么在电脑上用手机app软件
  • 公司做网站有意义么网站认证必须做么
  • 网站虚拟空间更新缓存php外贸网站建设
  • 河南省建设执业资格注册中心网站门户定制网站建设公司