Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Sound / Audio / Wav or mp3

  1. #11
    hi Yvonne,

    You think I'd need to install pywin32 for this to work? If yes then 64 bit or 32 bit duh :-/

    Cheers,
    Murali

  2. #12

    Lightbulb Lianja - Python - PyAudio - pyglet

    hi,

    I managed to get the audio working from within Lianja. I spent a whole night figuring that out :-)

    Here is a solution in case anyone is interested in playing (cross-platform!) sounds from Lianja. Initially I tried pyglet which seemed good but I had some issues getting it to work. I settled for PyAudio which can be found here: http://people.csail.mit.edu/hubert/pyaudio/

    I used PyAudio for Python 2.7 found on that page
    md5sum: 3bb90b71f294d2bcf89f0cdb035c31e7

    And here is the code (Courtesy: Guz Alexander) that plays the sound

    Code:
    import pyaudio
    import wave
    
    chunk = 1024
    wf = wave.open('thesong.wav', 'rb')
    p = pyaudio.PyAudio()
    
    stream = p.open(
        format = p.get_format_from_width(wf.getsampwidth()),
        channels = wf.getnchannels(),
        rate = wf.getframerate(),
        output = True)
    data = wf.readframes(chunk)
    
    while data != '':
        stream.write(data)
        data = wf.readframes(chunk)
    
    stream.close()
    p.terminate()


    Cheers,
    Murali

  3. #13
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,353
    Blog Entries
    22
    Helpful for all. Thanks for sharing that Murali. That's what a community is all about, everyone helps each other.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  4. #14
    Yup, most welcome.

    Cheers,
    Murali

  5. #15
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,187
    Excellent!

    thanks,

    Hank

  6. #16
    You are welcome :-)

    Cheers,
    Murali

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us