前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >用Python实现语音播报

用Python实现语音播报

作者头像
py3study
发布2020-01-06 15:08:42
2.7K0
发布2020-01-06 15:08:42
举报
文章被收录于专栏:python3python3

以下内容为带着儿子一起学Python的实现记录,为自己保存下来,也希望对其他学习者有用!

1. 确保已经安装python,本例使用python,操作系统为:Windows 10 专业版;

2. 设置环境变量,设置两个path路径。

E:\Python27 和E:\Python27\Scripts(为安装时选择的路径)

3. 查看Python以及pip安装成功

3.1 查看Python,开始菜单->输入cmd->输入python,正常显示如下图:

3.2查看pip,在步骤3.1中按Ctrl+C退出python,输入pip,正常显示如下图:

4. 安装pyttsx,在命令行输入pip install pyttsx,安装完成如下图:

  python3,在命令行输入pip3install pyttsx3

5. 安装pywin32,

Step 2: Installing pywin32

The pyttsx library/package has a dependence of pywin32,so you need to install this package also. In this using pip is not a good ideaand most circumstances the installation will fail. So the best method isinstall pywin32 is by downloading the .exe file from the pywin32 Source Forge website.(老的版本:)

New downloadscan now be found at https://github.com/mhammond/pywin32/releases All buildsfrom Build 222 and later can be found *only* on github.(新版本)

选择好对应的版本,我安装的py2.4-amd64,因此,选择红框中的版本进行安装。

官方说明:

To downloadpywin32 binaries you must choose both the correct Python version and"bittedness".

Note that thereis one download package for each supported version of Python - please checkwhat version of Python you have installed and download the correspondingpackage.

Some packageshave a 32bit and a 64bit version available - you must download the one whichcorresponds to the Python you have installed. Even if you have a 64bitcomputer, if you installed a 32bit version of Python you must install the 32bitversion of pywin32.

To determinewhat version of Python you have, just start Python and look at the first lineof the banner. A 32bit build will look something like

Python2.7.2+ ... [MSC v.1500 32 bit (Intel)] on win32

While a 64bitbuild will look something like:

Python2.7.2+ ... [MSC v.1500 64 bit (AMD64)] on win32

我电脑查看出来的结果:

4.1 出错解决

安装时,出现如下错误:

closefailed in file object destructor:sys.excepthook is missing lost sys.stderr

解决如下:(参考:http://www.bubuko.com/infodetail-2089657.html)

(1)右键管理员身份运行cmd命令提示符:

(2)切换到E:\Python27\Scripts文件夹下,命令为:cdE:\Python27\Scripts

最上面的小红框告诉我们当前处于管理员模式命令提示符

(3)运行python pywin32_postinstall.py -install

(4)退出命令行

参考:

http://blog.sina.com.cn/s/blog_9f0384e70102yk74.html

http://blog.csdn.net/marksinoberg/article/details/52137547

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-09-16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Step 2: Installing pywin32
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档