GithubHelp home page GithubHelp logo

Comments (7)

korakot avatar korakot commented on May 12, 2024 7

I followed the rich output example, and it works for me.

from IPython.display import Audio
Audio(url="http://www.nch.com.au/acm/8k16bitpcm.wav")

This one generates 2 sine waves.

import numpy as np
max_time = 3
f1 = 220.0
f2 = 224.0
rate = 8000.0
L = 3
times = np.linspace(0,L,rate*L)
signal = np.sin(2*np.pi*f1*times) + np.sin(2*np.pi*f2*times)

Audio(data=signal, rate=rate)

from colabtools.

korakot avatar korakot commented on May 12, 2024 2

I have tried and found 2 methods to play midi in Colab.
The simpler one is to convert midi to wav as in this gist.

Another one use midi.js to play midi file directly.
See my "unorganized" notebook. (a few failures with other methods)
https://colab.research.google.com/drive/1iliUIN1Jn8552XEiYBYEYimSm7yiOJ8x

from colabtools.

deepakee13 avatar deepakee13 commented on May 12, 2024 1

How do we play sound using numpy data through python file on Notebook in google colab?

from colabtools.

gschennerg avatar gschennerg commented on May 12, 2024

Hi,
I still struggle to play a midi file in a colaboratory notebook. All the examples i found so far are jupyter notebooks (with music21 for example) that require the installation of some additional programs like musescore etc. on the local machine to play the midi files. These notebooks did not work in the colaboratory environment.
Has anybody succeeded to play a midi-file in the colaboratory environment? It would be nice to see such a notebook (with all the required installation steps apt-get...).

from colabtools.

gschennerg avatar gschennerg commented on May 12, 2024

This is great! With your code i was able to play a midi file (i.e. convert to wav and show it in the notebook) like this:

!apt install fluidsynth
!cp /usr/share/sounds/sf2/FluidR3_GM.sf2 ./font.sf2
!pip install midi2audio
from midi2audio import FluidSynth
from IPython.display import Audio

FluidSynth("font.sf2").midi_to_audio('test.midi', 'test.wav')
Audio("test.wav")

Thanks a lot!

from colabtools.

kungkingc avatar kungkingc commented on May 12, 2024

thanks this really helped :)

from colabtools.

lidija-jovanovska avatar lidija-jovanovska commented on May 12, 2024

This really works. Thanks so much!

from colabtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.