#  this is a test script
#  i have a folder with the mp3 files named from music1 to music8.
#  it random choses the files . no problem
#  but i want to change the sleep(120) so the next starts when the previous is finished

from java.lang import String
from org.myrobotlab.service import Speech
from org.myrobotlab.service import Sphinx
from org.myrobotlab.service import Runtime
import random




mouth = Runtime.createAndStart("mouth","Speech")




def play():
    for y in range(0, 8):
        number = str(random.randint(1, 8))
        mouth.audioFile.playFile("C:\Users\Markus\Music\Robynsfavoriter\music" + str(number) + ".mp3", False)
        print number
        mouth.speak("playing song number" + str(number))
        sleep(120)
        mouth.audioFile.silence()


play()



@@ -388,19 +388,16 @@
 random%0A%0A
-%0A%0A%0A
 mouth = 
@@ -438,17 +438,143 @@
 eech%22)%0A%0A
-%0A
+# add python as a listener of the %22stopped%22 event from audioFile%0Amouth.audioFile.addListener(%22stopped%22, python.name, %22stopped%22)
 %0A%0Adef pl
@@ -648,16 +648,63 @@
 (1, 8))%0A
+        # usually you need to escape backslash%0A
         
@@ -736,27 +736,31 @@
 %22C:%5C
+%5C
 Users%5C
+%5C
 Markus%5C
+%5C
 Music%5C
+%5C
 Roby
@@ -771,16 +771,17 @@
 voriter%5C
+%5C
 music%22 +
@@ -942,16 +942,127 @@
 ence()%0A%0A
+# stopped method is called when at the end of an audio file%0Adef stopped():%0A    print(%22I have stopped playing%22)%0A
 %0Aplay()%0A

Update mp3test.py