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

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

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

本文實(shí)例講述了python將文本轉(zhuǎn)換成語(yǔ)音的方法。分享給大家供大家參考。具體實(shí)現(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!")

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

相關(guān)文章

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

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

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

    Python Pandas學(xué)習(xí)之?dāng)?shù)據(jù)離散化與合并詳解

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

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

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

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

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

    Python文件監(jiān)聽(tīng)工具pyinotify與watchdog實(shí)例

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

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

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

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

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

    Python動(dòng)態(tài)導(dǎo)入模塊的方法實(shí)例分析

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

    Python3.10新特性之match語(yǔ)句示例詳解

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

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

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

最新評(píng)論