python实现语音播放_用Python实现语音播报
以下內容為帶著兒子一起學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
(1)右鍵管理員身份運行cmd命令提示符:
(2)切換到E:\Python27\Scripts文件夾下,命令為:cdE:\Python27\Scripts
最上面的小紅框告訴我們當前處于管理員模式命令提示符
(3)運行python pywin32_postinstall.py -install
(4)退出命令行
參考:
總結
以上是生活随笔為你收集整理的python实现语音播放_用Python实现语音播报的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序中如何实现轮播图
- 下一篇: websocket python爬虫_p