【问题标题】:Playing multiple sounds in one Jupyter Notebook cell在一个 Jupyter Notebook 单元中播放多种声音
【发布时间】:2018-05-09 14:57:49
【问题描述】:

问题类似于Automatically play sound in IPython notebook - 不同之处在于我需要多次播放声音。在浏览器端 - 而不是服务器端。

最幼稚的做法:

IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg", autoplay=True)
time.sleep(10)
IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg", autoplay=True)

不起作用,因为它只播放一次声音。此外,IPython.display.Audio 对象似乎有必要作为单元格的输出,如:

IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg", autoplay=True)
None

没有声音。

不能将代码拆分为多个单元格。

【问题讨论】:

    标签: python ipython jupyter-notebook jupyter


    【解决方案1】:

    我已经想通了(并稍微清理了我的代码):

    horse = IPython.display.Audio(url="http://www.w3schools.com/html/horse.ogg",
                                  autoplay=True)
    IPython.display.display(horse)
    time.sleep(10)
    IPython.display.display(horse)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      相关资源
      最近更新 更多