-
Notifications
You must be signed in to change notification settings - Fork 138
/
starting_sound.py
32 lines (26 loc) · 1 KB
/
starting_sound.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 10/05/2015
# Load a mp3 sound from the Web URL and save it localy (by default the directory from where you start MRL
# test on Pc-win7 only...
from org.myrobotlab.service import Speech
import urllib2
import os
# The directory where the file will be saved default = current directory
#currentdir=os.getcwd()
# To set a directory
# os.chdir("h:/mrl/sound")
os.chdir("C:/myrobotlab/myrobotlab.1.0.107/audioFile/google/en_gb/audrey")
# the name of the local file
# remove the file if it already exist in the Audiofile directory
soundfilename="starting mouth.mp3";
try:
mp3file = urllib2.urlopen('http://www.inmoov.fr/wp-content/uploads/2015/05/starting-mouth.mp3')
output = open(soundfilename,'wb')
output.write(mp3file.read())
output.close()
except IOError:
print "Check access right on the directory"
except Exception:
print "Can't get the sound File ! Check internet Connexion"
# Start the sound...
mouth = Runtime.createAndStart("mouth","Speech")
mouth.audioFile.playFile(currentdir+"/"+soundfilename, False)