# Nous construisons ensuite la requête pour obtenir le temps actuel.
openWeatherMapQuery = {
    'q': 'Rennes, France',
    'lang': 'fr',
    'units': 'metric',
    'appid': '0885ba357698e289ada592480c0cb75e'
}
openWeatherMapURL = "http://api.openweathermap.org/data/2.5/weather?"+ urllib.urlencode(openWeatherMapQuery)

# Nous procédons ensuite à la requête de l'API.
r = requests.get(openWeatherMapURL)
if r.status_code >= 400 :
    print "Failed to call openWeatherMapURL on ",openWeatherMapURL
    exit(1)

resp=r.json()
print resp

# Nous construisons le texte à réciter.
text = u"Bulletin météo : " + resp['weather'][0]['description']

# Ensuite, nous ajoutons la température pour conclure la phrase. Notez, que nous l'arrondissons.
text = text + u". A Rennes, il fait actuellement "+ str(resp['main']['temp']).replace('.',',') +u" degrés."

#print text

play_audio_files([ conf['CORE_ROOT'] + "/resources/mp3/weather/fr/signature.mp3"])
play_tts(text.encode('utf8'), 'fr')
play_audio_files([ conf['CORE_ROOT'] + "/resources/mp3/weather/fr/signature.mp3"])
Exemplo n.º 2
0
#!/usr/bin/python

import datetime
import random
import os

from core.tools.config import getConfig
from core.functions.play_audio import play_audio_files

conf = getConfig()
print(conf)

if __name__ == "__main__":
    hour = datetime.datetime.now().strftime('%H').lstrip("0")

    files = os.listdir( conf['CORE_ROOT'] + "/resources/mp3/clock/fr/" + hour )
    random.shuffle(files)
    print files[0]
    play_audio_files([
        conf['CORE_ROOT'] + "/resources/mp3/clock/fr/signature.mp3",
        conf['CORE_ROOT'] + "/resources/mp3/clock/fr/" + hour + "/"+files[0],
        conf['CORE_ROOT'] + "/resources/mp3/clock/fr/signature.mp3"])
Exemplo n.º 3
0
#!/usr/bin/python

import random
import os

from core.tools.config import getConfig
from core.functions.play_audio import play_audio_files

conf = getConfig()
print(conf)

if __name__ == "__main__":
    files = os.listdir( conf['CORE_ROOT'] + "/resources/mp3/surprise/fr/" )
    random.shuffle(files)
    print files[0]
    play_audio_files([conf['CORE_ROOT'] + "/resources/mp3/surprise/fr/" +files[0] ])