No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

This is a sample of weather bot written in python


The following installation steps is for windows, for posix users, it's recomended to use your system package manager.

  1. Install python3

Remember to check the option to add the python system variable during the installation.

  1. Launch command line prompt

Press shortcut win+R and type in cmd to launch command line prompt, it's recommended to use powershell for windows users, just replace cmd with powershell.

  1. Install python package
pip install SpeechRecognition pyaudio python-forecastio gtts

  1. Download this project from github

  1. Download mpv player, if you want to use windows media player, you can replace the player location in the code with the new location.

Download mpv

Download 7z , if you can unzip the 7zip file.

Finally move the mpv.exe into this project folder.

  1. Execute the following code

open the folder and open the with editor(ex. python IDLE)

Edit the following code, replace the api key with your own weather api key got from this website.

Sign up a new account and get an api key.

# This version is for windows, and there must be a mpv application in this work directory

import forecastio
from gtts import gTTS
import subprocess

api_key = 'Enter your api key'

# the following coordinate is Taipei/Taiwan
lat = 25.0391667
lng =  121.525
lang = 'zh-TW'
file_name = 'weather.mp3'
player = './mpv'

forecast = forecastio.load_forecast(api_key, lat, lng)

by_hour = forecast.hourly()

for data in
    text = '' + str(data.time) + '氣溫是' +  str(data.temperature) + '度西'
    tts = gTTS(text, lang)[player, file_name])