1.[代码][Python]代码

# 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将文字转换为语音_python实现将文本转换成语音相关推荐

  1. python对象列表转换为字典_python实现class对象转换成json/字典的方法

    本文实例讲述了python实现class对象转换成json字典的方法.分享给大家供大家参考,具体如下: # -*- encoding: UTF-8 -*- class Student: name = ...

  2. 几行代码就搞定一个文字识别功能,同时还能转换成语音,畅快!

    前几天想把一篇不错的文章保存下来,无奈是图片的,于是想利用python把图片中的文字识别出来 实现的方式还是挺多的,这里介绍下百度的AI开放平台,毕竟大公司,感觉识别的精度会高点,同时相信他们的算法也 ...

  3. .NET 将文本转换成语音 (转)

    用过金山词霸的都知道金山词霸里有个功能能够将单词按其读音读出来.也许会有人认为它是事先将所有的单词的读音文件存储在数据库里,然后事需要的时候再调用.其实事实上并不是这样,我们有更好的解决办法,MS就专 ...

  4. python将list转换为dataframe_Pandas把dataframe或series转换成list的方法

    把dataframe转换为list 输入多维dataframe: df = pd.DataFrame({'a':[1,3,5,7,4,5,6,4,7,8,9], 'b':[3,5,6,2,4,6,7, ...

  5. python调用迅雷下载引擎_python将下载地址转换成迅雷和qq旋风的下载地址

    迅雷和qq旋风下载,有加速和离线功能,很方面,我是在网上看到的原始地址和迅雷地址,qq旋风地址的转化原理,然后用python+pyqt写了一个客户端 原理: 迅雷: 迅雷下载地址="thun ...

  6. python处理时间格式时分秒_python将时分秒转换成秒的实例

    处理数据的时候遇到一个问题,从数据库里导出的数据是时分秒的格式:hh:mm:ss ,现在我需要把它转换成秒,方便计算. 原数据可能分两种情况,字段有可能是文本字符串类型的,也有可能是时间类型,他们的处 ...

  7. python 数字转化excel行列_Python 3 实现数字转换成Excel列名(10进制到26进制的转换函数)...

    背景: 最近在看一些Python爬虫的相关知识,讲爬取的一些数据写入到Excel表中,当时当列的数目不确定的情况下,如何通过遍历的方式讲爬取的数据写入到Excel中. 开发环境: Python 3  ...

  8. python字符串转化为浮点_python如何将字符串转换成浮点型

    python将字符串转换成浮点型的方法:可以利用float()函数来实现.float()函数用于将整数和字符串转换成浮点数并返回,具体使用方法如:[num1 = "123.12"; ...

  9. python里class转换_python实现class对象转换成json/字典的方法

    python实现class对象转换成json/字典的方法 发布于 2016-03-28 08:05:44 | 153 次阅读 | 评论: 0 | 来源: 网友投递 Python编程语言Python 是 ...

最新文章

  1. python input和print,Python基础——输出[print()]与输入[input()]
  2. 我还不懂什么是分布式事务
  3. 浙江大学医学院附属儿童医院倪艳组招聘博士后和科研助理-肠道微生物和代谢方向...
  4. python函数定义中参数列表里的参数是_详解Python函数中参数带星号是什么意思
  5. 了解的四大关键性概念
  6. 分层设计与领域设计融合架构设计
  7. 正则表达式(开源框架)
  8. 实操将TensorFlow模型部署成Docker服务化
  9. [转]《吐血整理》系列-顶级程序员工具集
  10. Axure5.1不能输入中文问题.
  11. 数据库MySQL基础---JDBC开发步骤--JDBC封装工具类--PreparedStatement实现CRUD操作
  12. 报线上python课程靠谱吗-Python培训线上和线下有什么区别?
  13. win10user文件夹迁移_Win10纯净版下迁移用户文件的技巧
  14. Unity Scroll View在Clamped模式下无法移动
  15. div设置为可获取焦点并且判断是否已获取焦点的方法
  16. 英语中what的用法
  17. java毕业设计项目基于JavaWeb酒店管理系统开发与设计
  18. 消息推送----微信小程序,公众号
  19. 图片裁剪工具vueCropper跨域解决
  20. 拥抱AI!人工智能如何在疫情期间重塑娱乐业?

热门文章

  1. shell编程快速入门及实战
  2. SQL Server监控全解析
  3. JavaSE的输入流、输出流
  4. java多线程(二)——锁机制synchronized(同步方法)
  5. Sublime Text 全程指南
  6. 解决mysql“Access denied for user 'root'@'localhost'”
  7. Windows Phone 7 自定义弹出窗口
  8. 2.4、准备Spring Boot的环境 prepareEnvironment
  9. RTOS原理与实现07:邮箱实现
  10. RTOS原理与实现04:任务管理模块