Sixteen Hours

    That's approximately how long it took for me to figure out how to code so that my repl would  play audio along with my image (sort of.)  But the journey there is worth noting, along with the anxiety and laser focus and eureka moment which came on Monday morning at 4am.

    Let me start with my reaction to receiving the assignment via Moodle that I was to expand my "current Python code to include actual sound files." [Gulp!]. I had already gone down that rabbit hole the week before and failed miserably.  My professor gave me this suggestion:


     This was the avenue I had tried last week...unsuccessfully.


My professor then added:

If you are feeling like it, you could also try to have the playing of the sounds triggered to certain events in your program. For example, one sound file plays when a turtle is at a particular x,y position.

🤣

    OK...I'm not one to back down to a challenge! Determined to, at the very least, have music play while my Musical Moment image was unfurling, I began to Google in earnest.


    I began with Playsound...again. But what is Playsound?


    Playsound is a platform that I needed to install but first needed install a pip.  Ugh! What's a pip?


    Oh! So Python already has a pip? Damned if I could find it and when I tried to code to install Playsound on my Main.py...



    Among other things, I got this...

    This sent me down the path of looking up "what is a ParseError?" "what is a bad token?" "what is a module?", etc. 

    There's an 1950s rom com called Born Yesterday starring Judy Holliday and Broderick Crawford about a woman whose boorish husband decides she's not smart enough and gives William Holden the task of 'smarting her up'.  He gives her a small dictionary to circle in red and look up every word in the newspaper that she doesn't understand.  The joke is, of course, that by the time she's done with the paper, almost every word is circled and she has no overarching comprehension of anything she's read.  That's how I was feeling by the time I got to...


    Undaunted, I googled further and discovered that I was not the only one who had difficulties in  playing audio on Python/Turtles. I found many comments from frustrated coders.  Codegrepper.com offered several options to click into and I jumped in! 


     I chose how to play music in Python and got these options...


    Yep...back to Playsound again.  I tried each of these codes and none worked or even got me closer to understanding what it was I was trying to code. There's the rub! My base knowledge, my conceptual framework for what I was trying to do was very limited.

I tried at least a dozen of the other sound or audio-related options from the site... 

and found myself no closer to affirmation or illumination. Or music.

    Then the questions began to pop ~ which is my favorite part of any process.

1)    Was my OS able to run Playsound? (Yes)
2)    Was there an error in the coding? (Not sure)
3)    Was I missing a step? (Probably)
4)    Is the problem in my audio file? (Tested..ok.)
5)    Is there a problem with mp3. Should I use .wav? (Tried both)
6)    Where is the program going to retrieve the audio file from? (Tried various options.)
7)    Where is the program going to put my audio file (Finally figured that one out.)

    I won't bore you, Dear Reader, describing the pages and pages of websites that I read and YouTubes I watched trying to figure out where the glitch was. No doubt my professor will look and immediate see the problem.  (I'm still a debugging newbie.)

    Then I asked myself questions, 8) I'm working in replit.com...is that different? and 9) Is Python different from Python/Turtle?  I'm thinking...MAYBE!

    I switched from accessing Python/Turtle repls to Python repls and was able to get my pretty image to run and also to get my music into the File:


    Recognition.  At least the .wav audio file that I had successfully put into the Files was recognized by the program...though it wouldn't play the music.  And it also wouldn't run my image which it HAD, prior to my adding the audio player.  (Audible sigh.)

    Digging deeper, I found a site that suggested going the HTML route and had me access music from Free Music Archive (I chose, Carmina Burana's O Fortuna, a pounding, angry and frenetic piece that reflected my mood!) and used an URL code to 1) put the audio file into my Files and 2) to create a music player that would recognize the file and...

    

   EUREKA!

        The program was actually running the audio!

        No...it still wasn't running my image. So...I'll post this blog entry today and keep working on this until Thursday's class.

        It's only Tuesday...and I'm always hopeful.

~ J


    

    

    


    

    




    






Comments

  1. January,
    As usual, you were incredibly persistent, resilient, and resourceful in making this work. And I love the Born Yesterday allusion.
    Could you share a link to your Replit? I would love to see your code.

    ReplyDelete
    Replies
    1. Hi Dr. A, Here ya go...https://replit.com/@akselradJ/GonnaGetMusic. Much to discuss during class :) . J

      Delete
  2. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular Posts