最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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)文章

  • wxpython繪制音頻效果

    wxpython繪制音頻效果

    這篇文章主要為大家詳細(xì)介紹了wxpython繪制音頻效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • python一行代碼就能實(shí)現(xiàn)數(shù)據(jù)分析的pandas-profiling庫(kù)

    python一行代碼就能實(shí)現(xiàn)數(shù)據(jù)分析的pandas-profiling庫(kù)

    這篇文章主要為大家介紹了python一行代碼就能實(shí)現(xiàn)數(shù)據(jù)分析的pandas-profiling庫(kù),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2024-01-01
  • Python中itertools的用法詳解

    Python中itertools的用法詳解

    循環(huán)器(iterator)是對(duì)象的容器,包含有多個(gè)對(duì)象。這篇文章主要介紹了python itertools用法,需要的朋友可以參考下
    2020-02-02
  • 使用Pytorch實(shí)現(xiàn)Swish激活函數(shù)的示例詳解

    使用Pytorch實(shí)現(xiàn)Swish激活函數(shù)的示例詳解

    激活函數(shù)是人工神經(jīng)網(wǎng)絡(luò)的基本組成部分,他們將非線性引入模型,使其能夠?qū)W習(xí)數(shù)據(jù)中的復(fù)雜關(guān)系,Swish 激活函數(shù)就是此類激活函數(shù)之一,在本文中,我們將深入研究 Swish 激活函數(shù),提供數(shù)學(xué)公式,探索其相對(duì)于 ReLU 的優(yōu)勢(shì),并使用 PyTorch 演示其實(shí)現(xiàn)
    2023-11-11
  • Python鼠標(biāo)事件及坐標(biāo)獲取窗口和屏幕坐標(biāo)

    Python鼠標(biāo)事件及坐標(biāo)獲取窗口和屏幕坐標(biāo)

    這篇文章主要介紹了Python編程中如何通過鼠標(biāo)事件及坐標(biāo)獲取窗口坐標(biāo)和屏幕坐標(biāo)的示例解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2021-10-10
  • Python WSGI的深入理解

    Python WSGI的深入理解

    這篇文章主要給大家介紹了關(guān)于Python WSGI的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-08-08
  • Python實(shí)現(xiàn)快速多線程ping的方法

    Python實(shí)現(xiàn)快速多線程ping的方法

    這篇文章主要介紹了Python實(shí)現(xiàn)快速多線程ping的方法,實(shí)例分析了Python多線程及ICMP數(shù)據(jù)包的發(fā)送技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-07-07
  • Python調(diào)用兩個(gè)機(jī)器人聊天的實(shí)戰(zhàn)

    Python調(diào)用兩個(gè)機(jī)器人聊天的實(shí)戰(zhàn)

    本文主要介紹了Python調(diào)用兩個(gè)機(jī)器人聊天,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Python設(shè)置和解除Word文檔保護(hù)的實(shí)現(xiàn)步驟

    Python設(shè)置和解除Word文檔保護(hù)的實(shí)現(xiàn)步驟

    在日常工作和學(xué)習(xí)中,我們經(jīng)常需要使用Word文檔來記錄和分享重要的信息,為了確保文檔內(nèi)容的安全性和完整性,了解如何保護(hù)和取消保護(hù)Word文檔顯得尤為重要,這篇博客將詳細(xì)介紹如何使用Python設(shè)置和解除Word文檔的保護(hù),需要的朋友可以參考下
    2025-02-02
  • Python中閉包與lambda的作用域解析

    Python中閉包與lambda的作用域解析

    這篇文章主要介紹了Python中閉包與lambda的作用域解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-07-07

最新評(píng)論

荃湾区| 江陵县| 蒲江县| 崇明县| 左权县| 大兴区| 富民县| 克什克腾旗| 高陵县| 福安市| 商南县| 定兴县| 陆河县| 汤原县| 双牌县| 英德市| 泽普县| 南乐县| 汝阳县| 福清市| 静乐县| 和政县| 饶平县| 庐江县| 承德县| 扬州市| 洛宁县| 宁乡县| 宜川县| 昌吉市| 石台县| 桐乡市| 舞钢市| 溧水县| 常熟市| 丹巴县| 京山县| 曲周县| 华蓥市| 萨嘎县| 襄城县|