(text)
| 59 | current_bar += 1 |
| 60 | |
| 61 | def speak(text): |
| 62 | global i |
| 63 | tts = gTTS(text=text, lang='en',slow=False) |
| 64 | tts.save('speech{}.mp3'.format(i%2)) |
| 65 | # playback the speech |
| 66 | mixer.music.load('speech{}.mp3'.format(i%2)) |
| 67 | mixer.music.play() |
| 68 | # wait for playback to end |
| 69 | while mixer.music.get_busy(): |
| 70 | time.sleep(.1) |
| 71 | mixer.stop() |
| 72 | i += 1 |
| 73 | |
| 74 | i = 0 |
| 75 | mixer.init() |