7
$\begingroup$

Is there a way to play a sound after a script finishes ? For scripts taking between 30min and many hours (like the delaunay triangulation one from doomlysz), it's good to not have to check every 10 min if the job is done or not.

$\endgroup$
1
  • $\begingroup$ You could edit the scripts you use to play a sound (or run custom operator which plays the sound). See this post on StackOverflow for playing audio in python. $\endgroup$
    – gandalf3
    Commented Dec 18, 2013 at 7:06

2 Answers 2

5
$\begingroup$

You could play a MP3 file using the aud module

import aud
import time

sound = aud.Factory.file(pathToMP3 )
device = aud.device()
handle = device.play(sound)
# omit this to play full sound file
time.sleep(5) 
handle.stop()

Alternatively you could launch any external application as described here: Run an external application with the bge

$\endgroup$
3
  • 1
    $\begingroup$ It gives me this error today: AttributeError: module 'aud' has no attribute 'Factory' $\endgroup$
    – Gunslinger
    Commented Jan 30, 2020 at 11:08
  • $\begingroup$ Hm, the current version should stil support this docs.blender.org/api/current/aud.html you could post a new question for your 2.8? Version $\endgroup$
    – stacker
    Commented Jan 30, 2020 at 12:05
  • $\begingroup$ Yes, I know. Strange. Maybe my installation is broken somehow. $\endgroup$
    – Gunslinger
    Commented Jan 30, 2020 at 12:41
1
$\begingroup$

I solved this by using winsound. As it is for windows, it is not available to all blender user.

https://docs.python.org/2/library/winsound.html#module-winsound

I do a distinctive beep like this. I don't have to search for an suitable mp3.

import winsound

frequency = 2500  # Set Frequency To 2500 Hertz
duration = 1000  # Set Duration To 1000 ms == 1 second
winsound.Beep(frequency, duration)

I got it from this answer here:

https://stackoverflow.com/questions/6537481/python-making-a-beep-noise/45079462

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .