Play audio using online compiler
<p>I am working on a program, and I want to be able to play a mp3 file (preferably, though other files could work). The catch is that, unfortunately, I'm using an online compiler (<a href="http://repl.it" rel="nofollow">repl.it</a>), and I can't use a desktop compiler. In other words, I can't use pyglet, or really any package not part of the standard ones. I've looked all over stack exchange, google, and beyond, but I can't seem to find anything. I don't need to edit the file, just play it.</p>

<p>I am using chrome as my browser, and the computer I'm using is a chromebook.</p>

<p>Any help would be appreciated. Thanks!</p>

<p>Even if you could install a library for audio playback on the online REPL, wouldn't the sound be played back somewhere in the racks of a data center instead of your computer at home?</p>

<p>AFAIK, the only currently feasible solution to this problem is to use an online service that allows HTML output and to use the HTML5 <code>&lt;audio&gt;</code> tag to play back the desired sound on your local computer via your browser. I prefer to use <a href="http://jupyter.org/" rel="nofollow">Jupyter notebooks</a> for that.</p>

<p>IPython provides <a href="http://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.Audio" rel="nofollow">IPython.display.Audio</a> which turns a Python buffer, a <code>bytes</code> object or a NumPy array into an <code>&lt;audio&gt;</code> tag. You can try this immediately at <a href="https://try.jupyter.org/" rel="nofollow">https://try.jupyter.org/</a>. Note that this embeds the raw audio data into the notebook, making it quite large.</p>

<p>I normally prefer to save the resulting audio data to a sound file (e.g. a WAV file) and manually create an <code>&lt;audio&gt;</code> tag for it within a Markdown cell. You can of course also do this on <a href="https://try.jupyter.org/" rel="nofollow">https://try.jupyter.org/</a>.</p>

<p>If you want to share your results with others, you can for example use <a href="http://mybinder.org/" rel="nofollow">Binder</a>. Here is an example of a <a href="http://mybinder.org/repo/spatialaudio/communication-acoustics-exercises/notebooks/brir-solutions.ipynb" rel="nofollow">Jupyter notebook using HTML5 <code>&lt;audio&gt;</code> elements running interactively on Binder</a>. You can even install custom libraries on your Binder, see for example <a href="https://github.com/spatialaudio/communication-acoustics-exercises/blob/master/Dockerfile" rel="nofollow">my Dockerfile</a>.</p>

python audio compilation music