Example #1
0
class Numbers:

    env = ENV()

    def __init__(self, call=env.CALLSIGN, secret=env.SECRET, gpio=env.GPIO):

        self.secret = secret
        if (self.secret != True):
            self.call = Callsign(call)

        self.voice = Voice(self.env.VOICE_LANGUAGE,
                           self.env.VOICE_SPEED_SLOW)  #Slow Talking
        self.tx = TX(gpio)

    def numbers(self):
        setOne = ""
        setTwo = ""
        setThree = ""

        ## Gen random numbers
        for i in range(3):
            setOne += str(randrange(1, 10)) + ", "
            setTwo += str(randrange(1, 10)) + ", "
            setThree += str(randrange(1, 10)) + ", "

        message = (setOne * 3) + ". " + (setTwo * 3) + ". " + (setThree * 3)
        logging.info("Numbers: " + message)

        self.voice.buildAudio(message)
        self.tx.txOn()
        self.voice.playAudio()
        if (self.secret != True):
            self.call.cw()
        self.tx.txOff()
Example #2
0
    def __init__(self, call=env.CALLSIGN, secret=env.SECRET, gpio=env.GPIO):

        self.secret = secret
        if (self.secret != True):
            self.call = Callsign(call)

        self.voice = Voice(self.env.VOICE_LANGUAGE,
                           self.env.VOICE_SPEED_SLOW)  #Slow Talking
        self.tx = TX(gpio)
Example #3
0
    def __init__(self,
                 call=env.CALLSIGN,
                 api=env.OWM_API,
                 gpio=env.GPIO,
                 online=env.OWM_ONLINE):

        self.call = Callsign(call)
        self.tx = TX(gpio)
        self.apiKey = api
        self.online = online
Example #4
0
class Weather:

    env = ENV()
    voice = Voice()

    def __init__(self,
                 call=env.CALLSIGN,
                 api=env.OWM_API,
                 gpio=env.GPIO,
                 online=env.OWM_ONLINE):

        self.call = Callsign(call)
        self.tx = TX(gpio)
        self.apiKey = api
        self.online = online

    def readWeather(self, location='reno,usa'):
        try:
            owm = pyowm.OWM(self.apiKey)
            observation = owm.weather_at_place(location)
            w = observation.get_weather()
            self.online = True
        except:
            logging.warning("Weather Offline")
            self.online = False

            self.voice.buildAudio("Sorry. The weather is Offline")
            self.tx.txOn()
            self.voice.playAudio()
            self.call.cw()
            self.tx.txOff()

        if (self.online):
            temp = round(
                ((w.get_temperature()['temp'] - 275.15) * (9 / 5) + 32),
                1)  # K -> F
            rh = w.get_humidity()
            windSpeed = round((w.get_wind()['speed'] * 2.237), 1)  # MPS -> MPH
            windDirection = w.get_wind()['deg']

            report = "Air temperature, " + str(
                temp) + ". " + "Relative Humidity, " + str(
                    rh) + ". " + "Wind Speed, " + str(
                        windSpeed) + " Miles Per Hour. At " + str(
                            windDirection) + " degrees."
            logging.info("Weather: " + report)

            self.voice.buildAudio(report)
            self.tx.txOn()
            self.voice.playAudio()
            self.call.cw()
            self.tx.txOff()
        else:
            return
Example #5
0
class Time:

    env = ENV()
    voice = Voice()

    def __init__(self, call=env.CALLSIGN, gpio=env.GPIO):

        self.tx = TX(gpio)
        self.call = Callsign(call)

    def readDate(self):
        day = date.today().strftime("%A")
        month = date.today().strftime("%B")
        dayNumber = date.today().strftime("%-d")
        year = date.today().strftime("%Y")

        todaysDate = "Today is " + day + " " + month + " " + dayNumber + " " + year
        logging.info("Date: " + todaysDate)

        self.voice.buildAudio(todaysDate)
        self.tx.txOn()
        self.voice.playAudio()
        self.call.cw()
        self.tx.txOff()

    def readTime(self):
        hour = time.strftime("%-I")
        min = time.strftime("%M")
        pmAm = time.strftime("%p")

        timeNow = "The time is " + hour + " " + min + " " + pmAm
        logging.info("Time: " + timeNow)

        self.voice.buildAudio(timeNow)
        self.tx.txOn()
        self.voice.playAudio()
        self.call.cw()
        self.tx.txOff()
Example #6
0
class Audio:

    env = ENV()

    def __init__(self, call=env.CALLSIGN, gpio=env.GPIO):

        self.call = Callsign(call)
        self.tx = TX(gpio)

    def playWav(self, file):
        logging.info("Playing Wav: " + file)

        self.tx.txOn()
        os.system("aplay " + str(pathlib.Path().absolute()) + file)
        self.call.cw()
        self.tx.txOff()

    def playMp3(self, file):
        logging.info("Playing Mp3: " + file)

        self.tx.txOn()
        os.system("mpg123 " + str(pathlib.Path().absolute()) + file)
        self.call.cw()
        self.tx.txOff()
Example #7
0
 def __init__(self, env=env):
     self.env = env
     self.call = Callsign(self.env.CALLSIGN)
     self.tx = TX(self.env.GPIO)
Example #8
0
    def __init__(self, call=env.CALLSIGN, gpio=env.GPIO):

        self.tx = TX(gpio)
        self.call = Callsign(call)