Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Play Audio File w/ Python
#1
Hello!
I'm very new to using Python. I'm attempting to create code that will play an audio file based off an input.
I'm working on getting a robot to ask for help removing obstacles from its path when it can see that it cannot pass through. For example, if it is heading down a hall way and a chair is in the way of its path, it will repeatedly play audio asking for the obstacle to be removed. After playing the audio file it will reevaluate whether the obstacle is moved. If it is not, it will replay the file. This loop will continue until the obstacle is moved.
I'm uncertain of how to create the loop. As for the part of the code that evaluates the obstacle, I believe I can type that piece, it is the code for the audio I need assistance with.
Thank you so much for your help Big Grin and let me know if my question doesn't make sense or you need more info!
Reply
#2
What have you tried?
What software are you using? OS?
There is a lot of modules to play sound with python.
Check the pygame-mixer
Reply
#3
I've tried a couple of ways but they both require an arduino and separate speakers. I was hoping to use the speakers in the laptop as opposed to adding more hardware. To answer your other question, it is on OS
Reply
#4
I have used pygame-mixer, with headphone and speakers.
It works fine.
Reply
#5
Yeah, I was looking at the link just a few minutes ago. It looks like it should work perfectly for what I need
Reply
#6
apparently there's something new and annoying in pygame
see this post: https://python-forum.io/Thread-Annoyance...-of-pygame
Reply
#7
Thank you for letting me know. In the thread about the annoyance, people mentioned something called Godot...is that similar to pygame-mixer? Similar to the point that I could use it to run the audio file?
Reply
#8
godot is a game engine. I am not familiar at all with it, and apparently it has a high learning curve. So unless you plan on building games with godot, making a single audio program is way overkill. pygame.mixer would work better i think.
Recommended Tutorials:
Reply
#9
Take a look at pyglet.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  chua osillator to audio file sddfds 0 431 Jul-13-2023, 11:07 PM
Last Post: sddfds
  error python audio codiac 3 4,125 Mar-30-2023, 03:12 PM
Last Post: deanhystad
  How can I send a .mp3 to play through my mic? ejected 20 20,181 Sep-01-2022, 02:38 AM
Last Post: victormayer
  python audio analysis kiyoshi7 3 1,764 Feb-22-2022, 06:09 PM
Last Post: Axel_Erfurt
  Play the next music in a list Pymax 0 1,202 Jul-28-2021, 07:27 PM
Last Post: Pymax
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 3,962 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  Play fixed frequency sound in python 3 jpezz 2 2,771 Feb-07-2021, 08:21 PM
Last Post: jpezz
  how do i play an mp3 from a list gr3yali3n 3 2,131 Dec-01-2020, 08:50 AM
Last Post: Axel_Erfurt
  Handling multi-input/output audio in python bor1904 4 3,573 Nov-04-2020, 08:25 AM
Last Post: CHLOVRL
  Find frequencies of an audio file at a specific time via librosa jberesford123__ 0 2,329 Oct-21-2020, 01:18 PM
Last Post: jberesford123__

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020