gpt4 book ai didi

python - 谷歌实验室。 IPython.display - 音频在 if 语句中不起作用

转载 作者:行者123 更新时间:2023-12-02 22:52:20 25 4
gpt4 key购买 nike

刚开始学习Python。我在 if 语句中遇到了音频的奇怪行为。它应该工作,但没有工作。

请参阅此处示例:https://colab.research.google.com/drive/1Jz6znaj047zrtDK-orp8VN0869xDYnQO?usp=sharing

此代码工作正常(播放 wav 文件):

from IPython.display import Audio

sound_hey = "http://thecyberbuddy.com/sounds/hooray.wav"

Audio(sound_hey, autoplay=True) # plays ok

这不是:

from IPython.display import Audio

sound_boo = "http://mrclan.com/fastdl/tfc/sound/boo.wav"

s = 1

if s == 1:
Audio(sound_boo, autoplay=True) # dose not play...

最佳答案

这里

from IPython.display import Audio, display

sound_boo = "http://mrclan.com/fastdl/tfc/sound/boo.wav"

s = 1

if s == 1:
display(Audio(sound_boo, autoplay=True))

关于python - 谷歌实验室。 IPython.display - 音频在 if 语句中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63452619/

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