在jupyter的for循环中播放音频

编程入门 行业动态 更新时间:2024-10-27 01:33:05
本文介绍了在jupyter的for循环中播放音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有大量需要注释的训练数据,为此,我需要听一堆声音片段并记下我听到的声音.我在笔记本上为此写了一个小脚本.

I have a ton of training data I need annotated, in order to do so I need to listen through a bunch of sound snippets and note what I hear. I wrote a small script for this in a notebook.

我的主要问题是IPython显示循环显示.例如:

My main issue is that IPython display dosent show in loops. As an example:

import numpy import IPython.display as ipd sr = 22050# sample rate T = 2.0# seconds t = numpy.linspace(0, T, int(T*sr), endpoint=False)# time variable x = 0.5*numpy.sin(2*numpy.pi*440*t) ipd.Audio(x, rate=sr)

将出现一个音频框,我将可以播放正弦波.

will show up with an audio box, and I will be able to play the sine wave.

但是尝试在for循环中播放任何内容都不会产生任何结果(例如:)

But trying to play anything in a for loop yields nothing (such as:)

for i in range(10000000): x = 0.5*numpy.sin(i*numpy.pi*440*t) ipd.Audio(x, rate=sr)

如果任何人都有一个很好的解决方案来循环(和收听)一堆音频文件(一次,一次,因为我需要循环浏览成千上万个声音片段),我将非常感激! >

If anyone has a good solution for looping through (and listening) a bunch of audio files (one at a time, since I need to loop through potentially hundreds of thousands sound snippets), I would be very much appreciative!

推荐答案

要在for循环中显示音频文件,您需要将IPython.display.display与Audio对象一起使用,如下所示:

To display the audio files within the for loop, you need to use IPython.display.display with the Audio object like so:

import numpy import IPython.display as ipd for i in range(10000000): x = 0.5*numpy.sin(i*numpy.pi*440*t) ipd.display(ipd.Audio(x, rate=sr))

更多推荐

在jupyter的for循环中播放音频

本文发布于:2023-07-11 12:01:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093981.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:音频   jupyter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!