欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實現(xiàn)將文本轉(zhuǎn)換成語音的方法

 更新時間:2015年05月28日 12:46:38   作者:不吃皮蛋  
這篇文章主要介紹了python實現(xiàn)將文本轉(zhuǎn)換成語音的方法,涉及Python中pyTTS模塊的相關(guān)使用技巧,需要的朋友可以參考下

本文實例講述了python將文本轉(zhuǎn)換成語音的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:

# Text To Speech using SAPI (Windows) and Python module pyTTS by Peter Parente
# download installer file pyTTS-3.0.win32-py2.4.exe 
# from: http://sourceforge.net/projects/uncassist
# also needs: http://www.cs.unc.edu/Research/assist/packages/SAPI5SpeechInstaller.msi
# and pywin32-204.win32-py2.4.exe at this date the latest version of win32com
# from: http://sourceforge.net/projects/pywin32/
# tested with Python24 on a Windows XP computer  vagaseat  15jun2005
import pyTTS
import time
tts = pyTTS.Create()
# set the speech rate, higher value = faster
# just for fun try values of -10 to 10
tts.Rate = 1
print "Speech rate =", tts.Rate
# set the speech volume percentage (0-100%)
tts.Volume = 90
print "Speech volume =", tts.Volume
# get a list of all the available voices
print "List of voices =", tts.GetVoiceNames()
# explicitly set a voice
tts.SetVoiceByName('MSMary')
print "Voice is set ot MSMary"
print
# announce the date and time, does a good job
timeStr = "The date and time is " + time.asctime()
print timeStr
tts.Speak(timeStr)
print
str1 = """
A young executive was leaving the office at 6 pm when he found 
the CEO standing in front of a shredder with a piece of paper in hand. 
"Listen," said the CEO, "this is important, and my secretary has left. 
Can you make this thing work?"
"Certainly," said the young executive. He turned the machine on, 
inserted the paper, and pressed the start button.
"Excellent, excellent!" said the CEO as his paper disappeared inside 
the machine. "I just need one copy."
"""
print str1
tts.Speak(str1)
tts.Speak('Haah haa haah haa')
print
str2 = """
Finagle's fourth law:
 Once a job is fouled up, anything done to improve it only makes it worse.
"""
print str2
print
print "The spoken text above has been written to a wave file (.wav)"
tts.SpeakToWave('Finagle4.wav', str2)
print "The wave file is loaded back and spoken ..."
tts.SpeakFromWave('Finagle4.wav')
print
print "Substitute a hard to pronounce word like Ctrl key ..."
#create an instance of the pronunciation corrector
p = pyTTS.Pronounce()
# replace words that are hard to pronounce with something that 
# is spelled out or misspelled, but at least sounds like it
p.AddMisspelled('Ctrl', 'Control')
str3 = p.Correct('Please press the Ctrl key!')
tts.Speak(str3)
print
print "2 * 3 = 6"
tts.Speak('2 * 3 = 6')
print
tts.Speak("sounds goofy, let's replace * with times")
print "Substitute * with times"
# ' * ' needs the spaces
p.AddMisspelled(' * ', 'times')
str4 = p.Correct('2 * 3 = 6')
tts.Speak(str4)
print
print "Say that real fast a few times!"
str5 = "The sinking steamer sunk!"
tts.Rate = 3
for k in range(7):
  print str5
  tts.Speak(str5)
  time.sleep(0.3)
tts.Rate = 0
tts.Speak("Wow, not one mispronounced word!")

希望本文所述對大家的Python程序設(shè)計有所幫助。

相關(guān)文章

  • Numpy中的shape、reshape函數(shù)的區(qū)別

    Numpy中的shape、reshape函數(shù)的區(qū)別

    本文主要介紹了Numpy中的shape、reshape函數(shù)的區(qū)別,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-07-07
  • Python Pandas學習之數(shù)據(jù)離散化與合并詳解

    Python Pandas學習之數(shù)據(jù)離散化與合并詳解

    Pandas是python的一個數(shù)據(jù)分析包,該工具是為解決數(shù)據(jù)分析任務而創(chuàng)建的。本文將通過示例詳細為大家介紹一下Pandas的數(shù)據(jù)離散化與合并,需要的可以參考一下
    2022-02-02
  • 使用OpenCV實現(xiàn)仿射變換—平移功能

    使用OpenCV實現(xiàn)仿射變換—平移功能

    這篇文章主要介紹了使用OpenCV實現(xiàn)仿射變換—平移功能,需要的朋友可以參考下
    2019-08-08
  • Python學習筆記(一)(基礎(chǔ)入門之環(huán)境搭建)

    Python學習筆記(一)(基礎(chǔ)入門之環(huán)境搭建)

    本系列為Python學習相關(guān)筆記整理所得,IT人,多學無害,多多探索,激發(fā)學習興趣,開拓思維,不求高大上,只求懂點皮毛,作為知識儲備,不至于落后太遠。本文主要介紹Python的相關(guān)背景,環(huán)境搭建。
    2014-06-06
  • Python文件監(jiān)聽工具pyinotify與watchdog實例

    Python文件監(jiān)聽工具pyinotify與watchdog實例

    今天小編就為大家分享一篇關(guān)于Python文件監(jiān)聽工具pyinotify與watchdog實例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • Python中encode和encoding的區(qū)別小結(jié)

    Python中encode和encoding的區(qū)別小結(jié)

    encode和encoding在Python中雖然都與字符編碼相關(guān),但它們的角色和用途是不同的,本文主要介紹了Python中encode和encoding的區(qū)別小結(jié),具有一定的參考價值,感興趣的可以了解一下
    2024-03-03
  • jupyter notebook 參數(shù)傳遞給shell命令行實例

    jupyter notebook 參數(shù)傳遞給shell命令行實例

    這篇文章主要介紹了jupyter notebook 參數(shù)傳遞給shell命令行實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04
  • Python動態(tài)導入模塊的方法實例分析

    Python動態(tài)導入模塊的方法實例分析

    這篇文章主要介紹了Python動態(tài)導入模塊的方法,結(jié)合實例形式較為詳細的分析了Python動態(tài)導入系統(tǒng)模塊、自定義模塊以及模塊列表的相關(guān)操作技巧,需要的朋友可以參考下
    2018-06-06
  • Python3.10新特性之match語句示例詳解

    Python3.10新特性之match語句示例詳解

    這篇文章主要為大家介紹了Python3.10新特性之match語句示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-02-02
  • 使用python實現(xiàn)mqtt的發(fā)布和訂閱

    使用python實現(xiàn)mqtt的發(fā)布和訂閱

    這篇文章主要介紹了使用python實現(xiàn)mqtt的發(fā)布和訂閱,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-05-05

最新評論