在IPython笔记本中自动播放声音 [英] Automatically play sound in IPython notebook

查看:84
本文介绍了在IPython笔记本中自动播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常在我的IPython笔记本中运行长时间运行的单元格。我希望笔记本能够在单元格执行完毕后自动发出蜂鸣声或播放声音。在iPython笔记本中有没有办法做到这一点,或者我可以在一个自动播放声音的单元格末尾放一些命令?

I often run long-running cells in my IPython notebook. I'd like the notebook to automatically beep or play a sound when the cell is finished executing. Is there some way to do this in iPython notebook, or maybe some command I can put at the end of a cell that will automatically play a sound?

如果有任何不同,我正在使用Chrome。

I'm using Chrome if that makes any difference.

推荐答案

你可以使用python的外部模块。尝试在单元格末尾从Snack Sound Toolkit添加此 s.play()调用。

You could use an external module with python. Try adding this s.play() call from Snack Sound Toolkit at the end of the cell.

Snack Sound Toolkit 可以播放wav,au和mp3文件。

The Snack Sound Toolkit can play wav, au and mp3 files.

s = Sound() 
s.read('sound.wav') 
s.play()

这个问题基本上是重复的:
用Python播放声音

this question is basically a duplicate of: Play a Sound with Python.

上面的代码片段来自@csexton。

The above code-snipit was from @csexton in that question.

这篇关于在IPython笔记本中自动播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆