3 python text-to-speech google-text-to-speech google-colaboratory
我试图在 google colab 中循环运行音频,但它没有给 mi 任何输出
from gtts import gTTS
from IPython.display import Audio
for voice in ["Aniket","sachin"]:
tts = gTTS("Hello {}".format(voice))
tts.save('1.wav')
sound_file = '1.wav'
Audio(sound_file, autoplay=True)
Run Code Online (Sandbox Code Playgroud)
输出我想要的是它应该听起来 hello aniket hello sachin 请帮忙
您只需要使用“IPython.display.display”方法,如下所示:
from gtts import gTTS
from IPython.display import Audio
from IPython.display import display
for voice in ["Aniket","sachin"]:
tts = gTTS("Hello {}".format(voice))
tts.save('1.wav')
sound_file = '1.wav'
wn = Audio(sound_file, autoplay=True) ##
display(wn)##
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6488 次 |
| 最近记录: |