python python中的文本到语音转换
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python python中的文本到语音转换相关的知识,希望对你有一定的参考价值。
import pyttsx3
engine = pyttsx3.init() # object creation
""" RATE"""
rate = engine.getProperty('rate') # getting details of current speaking rate
print ("rate is-",rate) #printing current voice rate
engine.setProperty('rate', 150) # setting up new voice rate
"""VOLUME"""
volume = engine.getProperty('volume') #getting to know current volume level (min=0 and max=1)
print ("volume is=",volume) #printing current volume level
engine.setProperty('volume',1.0) # setting up volume level between 0 and 1
"""VOICE"""
voices = engine.getProperty('voices') #getting details of current voice
engine.setProperty('voice', voices[0].id) #changing index, changes voices. o for male
# engine.setProperty('voice', voices[1].id) #changing index, changes voices. 1 for female
engine.say("Hello World!")
engine.say('My current speaking rate is ' + str(rate))
engine.runAndWait()
engine.stop()
以上是关于python python中的文本到语音转换的主要内容,如果未能解决你的问题,请参考以下文章
语音到文本的转换
Python实力操作-网页正文转换语音文件
python 带有os库的python中的文本到语音(TTS)
python将文本转换成语音的代码
Python语音识别错误转换mp3文件
Python + edge-tts:一行代码,让你的文本轻松变成语音!