#!/bin/bash
# HaveANiceDay
# Politeness according to the time of day
# version : 0.2
# Author  : Serge Le Tyrant
# License : CC-BY


# Requires the installation (in repository) of: gspeech pico2wave-shell pico-tts

# To be adapted according to your language
Morning="Bonne matinée"
Lunchtime="Bonne apétit !"
Afternoon="Bonne après-midi !"
Evening="Bonne soirée !"

# Working directory
Rep="/mnt/DDprc/Download/Goupil"

# Note: gspeech-cli does not support reading a variable containing a complete sentence (in this case it reads only the first word), but it does support a file containing the same message

   currenttime=$(date +%H:%M)
   if [[ "$currenttime" > "00:00" ]] && [[ "$currenttime" < "11:55" ]]; then
     echo $Morning>$Rep/Message.txt
   elif [[ "$currenttime" > "11:55" ]] && [[ "$currenttime" < "13:00" ]]; then
     echo $Lunchtime>$Rep/Message.txt
   elif [[ "$currenttime" > "12:55" ]] && [[ "$currenttime" < "18:00" ]]; then
     echo $Afternoon>$Rep/Message.txt
   else
     echo $Evening>$Rep/Message.txt
   fi

  gspeech-cli -s 0.9 -f $Rep/Message.txt -o speech.wav && aplay speech.wav
