我想在 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)
输出我想要的是它应该听起来hello aniket hello sachin Pleas help
最佳答案
你只需要使用“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)##
关于python - 如何在 Google colab 中循环播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65960537/