gpt4 book ai didi

python - 如何在 python 中生成声音输出..?

转载 作者:太空宇宙 更新时间:2023-11-04 08:10:39 26 4
gpt4 key购买 nike

我在 python 中生成随机数,如下所示,

print random.randrange(100, 1000, 2)

有什么方法可以将该输出转换为声音(音频)格式..?

最佳答案

如果你想改变速度:

import pyttsx
engine = pyttsx.init()
engine.setProperty('rate', 70)

voices = engine.getProperty('voices')
for voice in voices:
print "Using voice:", repr(voice)
engine.setProperty('voice', voice.id)
engine.say("Hi there, how's you ?")
engine.say("A B C D E F G H I J K L M")
engine.say("N O P Q R S T U V W X Y Z")
engine.say("0 1 2 3 4 5 6 7 8 9")
engine.say("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")
engine.say("Violet Indigo Blue Green Yellow Orange Red")
engine.say("Apple Banana Cherry Date Guava")
engine.runAndWait()

关于python - 如何在 python 中生成声音输出..?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23181409/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com