激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - python實現將文本轉換成語音的方法

python實現將文本轉換成語音的方法

2020-07-09 08:31不吃皮蛋 Python

這篇文章主要介紹了python實現將文本轉換成語音的方法,涉及Python中pyTTS模塊的相關使用技巧,需要的朋友可以參考下

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 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程序設計有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 日本不卡一二三区 | 青草伊人网 | 久久精品国产亚洲7777小说 | 欧美人人干 | 亚洲精品aaaaa | 国产剧情v888av | 成人不卡一区二区 | 成人不卡| 国产精品视频一区二区三区综合 | 亚洲精品成人久久久 | 香蕉久久久久久 | 精品国产一区二区亚洲人成毛片 | 精品黑人一区二区三区国语馆 | 特片网久久| 亚洲福利视频52 | 色999久久久精品人人澡69 | 久久久久久久久成人 | 一级电影在线观看 | 黄色免费在线电影 | 精国产品一区二区三区 | 久久最新免费视频 | 免费国产视频在线观看 | 午夜视频久久久 | 高清国产午夜精品久久久久久 | 亚洲少妇诱惑 | 久久久久久久久浪潮精品 | 国产激情网 | 免费毛片观看 | 久久夜色精品 | 黄网站在线播放视频免费观看 | 久久蜜桃香蕉精品一区二区三区 | 日韩精品中文字幕在线观看 | 高清一区二区在线观看 | 国产人成精品综合欧美成人 | 国产精品久久久久久久娇妻 | 美女av在线免费观看 | 国产视频在线观看一区二区三区 | 羞羞视频免费视频欧美 | 久久国产精品二国产精品中国洋人 | 日韩视频在线观看免费视频 | 国产精品久久av |