Giter VIP home page Giter VIP logo

Comments (2)

EdoardoMor avatar EdoardoMor commented on July 23, 2024

I think it should work like this, i will try it next weekend: (pseudo code):

import pyaudio import wave import numpy as np from Realtime_PyAudio_FFT import Visualization

Read audio file

audio_file = "path_to_audiofile.mp3" wf = wave.open(audio_file, 'rb')

Initialization of the PyAudio library and the Visualization object

p = pyaudio.pyAudio() visualization = visualization()

Set parameters for audio playback

stream = p.open( format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True, stream_callback=visualization.callback, # Callback callback function callback for animation )

Audio creation

data = wf.readframes(1024) whiledata: stream.write(data) data = wf.readframes(1024)

End the thread and clean up the resources

stream.stop_stream() stream.close() p.terminate()

Did you manage to write the full code and does it work?

from realtime_pyaudio_fft.

nordost8 avatar nordost8 commented on July 23, 2024

I think it should work like this, i will try it next weekend: (pseudo code):
import pyaudio import wave import numpy as np from Realtime_PyAudio_FFT import Visualization

Read audio file

audio_file = "path_to_audiofile.mp3" wf = wave.open(audio_file, 'rb')

Initialization of the PyAudio library and the Visualization object

p = pyaudio.pyAudio() visualization = visualization()

Set parameters for audio playback

stream = p.open( format=p.get_format_from_width(wf.getsampwidth()), channels=wf.getnchannels(), rate=wf.getframerate(), output=True, stream_callback=visualization.callback, # Callback callback function callback for animation )

Audio creation

data = wf.readframes(1024) whiledata: stream.write(data) data = wf.readframes(1024)

End the thread and clean up the resources

stream.stop_stream() stream.close() p.terminate()

Did you manage to write the full code and does it work?

do you want to specify the path to the file and see everything just like with the microphone? I could make a fork and add such functionality there, if someone really needs it :)

from realtime_pyaudio_fft.

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.