Vocal announcement - Good Morning Script
Moderator: leecollings
-
- Posts: 14
- Joined: Monday 19 December 2016 9:17
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Vocal announcement - Good Morning Script
With a little bit of help and a lot of work I have now a working announcement !
It's teaching me LUA !
Thanks !
It's teaching me LUA !
Thanks !
-
- Posts: 10
- Joined: Sunday 27 December 2015 21:24
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Vocal announcement - Good Morning Script
Hi
This script is a good idee
I need your help, instead of send the result in a vocal command I want to update a virtual text switch !
Below my script :
I have done this change
and I have following error :
[string "--[[ ..."]:169: 'end' expected (to close 'if' at line 23) near
tanks in advance
regards
This script is a good idee
I need your help, instead of send the result in a vocal command I want to update a virtual text switch !
Below my script :
Code: Select all
commandArray = {}
local timeNow= os.date("*t")
local curl='C:\\curl\\9\\bin\\curl.exe' --METTRE ICI LE CHEMIN DE VOTRE CURL
local tts_idx =337 -- idx capteur texte pour le tts
-- ############# REMISE A ZERO DE LA VARIABLE "BONJOUR" ENTRE 6H et 7H (la variable doit être de type chaîne) #################
if (timeNow.hour >=5 and timeNow.hour <6) then
commandArray['Variable:bonjour'] = tostring (0)
end
-- ############# CONDITIONS NECESSAIRES A L'EXECUTION DU SCRIPT #################
if (otherdevices['agenda google'] == 'On' and
timeNow.hour >=6 and
uservariables["bonjour"] == '0')
then
local sentence="Bonjour ! Nous sommes le " ..(os.date("%A")).. " " ..(os.date("%d")).. " " .. os.date("%B")
-- ############# PASSAGE DU JOUR ET DU MOIS EN FRANCAIS #################
local d = {
["Monday"] = " Lundi ",
["Tuesday"] = " Mardi ",
["Wednesday"] = " Mercredi ",
["Thursday"] = " Jeudi ",
["Friday"] = " Vendredi ",
["Saturday"] = " Samedi ",
["Sunday"] = " Dimanche ",
["01"] = " premier ",
["02"] = " deux ",
["03"] = " trois ",
["04"] = " quatre ",
["05"] = " cinq ",
["06"] = " six ",
["07"] = " sept ",
["08"] = " huit ",
["09"] = " neuf ",
["January"] = " Janvier ",
["February"] = " Février ",
["March"] = " Mars ",
["April"] = " Avril ",
["May"] = " Mai ",
["June"] = " Juin ",
["July"] = " Juillet ",
["August"] = " Août ",
["September"] = " Septembre ",
["October"] = " Octobre ",
["November"] = " Novembre ",
["December"] = " Décembre " }
for k, v in pairs (d) do
sentence = string.gsub(sentence, k, v)
end
-- ############# PROGRAMME D'ENCODAGE DU TEXTE POUR LE TTS #################
function url_encode(str)
if (str) then
str = string.gsub (str, "\n", "\r\n")
str = string.gsub (str, "([^%w %-%_%.%~])",
function (c) return string.format ("%%%02X", string.byte(c)) end)
str = string.gsub (str, " ", "+")
end
return str
end
-- ############# TEMPERATURE ET METEO #################
if (otherdevices['meteo local']) then --METTRE ICI VOTRE DEVICE DE TEMPERATURE
temperature1, hygro1, etat1= otherdevices_svalues['Température extérieure']:match("([^;]+);([^;]+)")
-- print("TEMP:"..temperature1);
-- print("HUM:"..hygro1);
end
sentence=sentence..". La température extérieure est de "..temperature1.." degré et le taux d'humidité est de "..hygro1.." pourcent. "
json = (loadfile "C:\\cURL\\9\\bin\\JSON.lua")() --METTRE ICI LE CHEMIN DU JSON
local city = "flagey-rigney"
local wuAPIkey = "XXXXXXXX"
local file=assert(io.popen(curl.. 'http://api.wunderground.com/api/'..wuAPIkey..'/forecast/lang:FR/q/France/'..city..'.json'))
local raw = file:read('*all')
file:close()
local jsonForecast = json:decode(raw)
prevision=jsonForecast.forecast.txt_forecast.forecastday[1].fcttext_metric -- Prévision complète
-- prevision=jsonForecast.forecast.simpleforecast.forecastday[1].conditions -- Prévision rapide
local t = {
["ºC"] = "degré",
[" ENE "] = " Est Nord Est ",
[" NNE "] = " Nord Nord Est ",
[" NE "] = " Nord Est ",
[" N "] = " Nord ",
[" NNO "] = " Nord Nord Ouest ",
[" NO "] = " Nord Ouest ",
[" SSE "] = " Sud Sud Est ",
[" SE "] = " Sud Est ",
[" S "] = " Sud ",
[" SSO "] = " Sud Sud Ouest ",
[" SO "] = " Sud Ouest ",
[" O "] = " Ouest ",
[" E "] = " Est ",
["km/h"] = " kilomètre heure" }
for k, v in pairs (t) do
prevision = string.gsub(prevision, k, v)
end
sentence=sentence.."Le temps de la journée sera "..prevision
-- ############# AJOUT RISQUE DE GIVRE #################
if (otherdevices_svalues['alerte givre'])=='Risque de givre' then
sentence=sentence.." Il y a peut etre du givre, soyez prudent."
elseif (otherdevices_svalues['Risque de givre'])=='Présence de givre !' then
sentence=sentence.." Attention il y a du givre, soyez très prudent!"
end
-- ############# AJOUT JOUR DES POUBELLES #################
month=tonumber(os.date("%m"))
day=tonumber(os.date("%d"))
-- TRash day : Mardi poubelle jaune (impair) / mardi poubelle verte (pair)
numOfWeek=tonumber(os.date("%V"))
numOfDay=os.date("%w")
if (numOfDay == '2') then -- mardi
if (numOfWeek % 2 ==0) then
sentence=sentence.."La poubelle verte est rammassé aujourd'hui." --pair
else
sentence=sentence.."La poubelle jaune est rammassé aujourd'hui." --impair
end
-- ############# ENCODAGE DU TTS #################
sentence = url_encode(sentence)
-- ############# SORTIE DU TEXTE #################
--print (sentence)
commandArray['UpdateDevice']= tts_idx ..'|0|'.. tostring(sentence) -- Mise à jour capteur txt
-- ############# PASSAGE DE LA VARIABLE BONJOUR A 1 POUR N'AVOIR LE MESSAGE QU'UNE SEULE FOIS PAR JOUR #################
commandArray['Variable:bonjour'] = tostring (1)
end
return commandArray
I have done this change
Code: Select all
-- ############# SORTIE DU TEXTE #################
--print (sentence)
commandArray['UpdateDevice']= tts_idx ..'|0|'.. tostring(sentence) -- Mise à jour capteur txt
[string "--[[ ..."]:169: 'end' expected (to close 'if' at line 23) near
tanks in advance
regards
-
- Posts: 3
- Joined: Wednesday 08 February 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.6653
- Location: Italy
- Contact:
Re: Vocal announcement - Good Morning Script
Hello to all,
Great work this script is trying on in my raspberry but even after several attempts of resolution, I can not figure out where I am wrong.
Do you know how to give me a hand?
Great work this script is trying on in my raspberry but even after several attempts of resolution, I can not figure out where I am wrong.
Do you know how to give me a hand?
Code: Select all
Error: EventSystem: in Notification: [string "indexCommand=1 ..."]:6: attempt to index global 'devicechanged' (a nil value)
Code: Select all
indexCommand=1
commandArray = {}
local timeNow= os.date("*t")
if devicechanged['test'] == 'On' and --Motion sensor Living Room ManualLaunchScript
timeNow.hour >=16 and
string.sub(uservariables_lastupdate['goodMorning'], 9, 10) ~= os.date("%d") -- Only one time per day
then
local sentence="Buongiorno, oggi è "..tonumber(os.date("%d")) -- Good morning, today we are the ..
....
-
- Posts: 3
- Joined: Wednesday 08 February 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.6653
- Location: Italy
- Contact:
Re: Vocal announcement - Good Morning Script
Everything solved ... at least I hope ... I have to put inside the lua editor of domoticz "UserVariable"
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Hi all,
This is great!! I would like to use this as well but i seem to not succeed in installing izsynth.
I did:
But then when I do the next I get a error
tried this but also no luck
Some help would be appriciated.
I am on a rpi2B
greetz
Jan
This is great!! I would like to use this as well but i seem to not succeed in installing izsynth.
I did:
Code: Select all
sudo apt-get update
sudo apt-get install -y sox lame mplayer curl espeak wget bsdmainutils file mawk coreutils
Code: Select all
pi@raspberrypi ~/domoticz/scripts $ izsynth -e naturalreaders -v Peter -t "Welco me home, mr Stark"
-bash: izsynth: no such command
Code: Select all
pi@raspberrypi ~/domoticz/izsynth $ cd /usr/local/bin
pi@raspberrypi /usr/local/bin $ wget https://raw.githubusercontent.com/ugoviti/izsynth/master/izsynth -O izsynth && chmod 755 izsynth
izsynth: Access denied
pi@raspberrypi /usr/local/bin $
I am on a rpi2B
greetz
Jan
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Nobody?
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Vocal announcement - Good Morning Script
According the WiKi you should do:
cd /usr/local/bin
wget https://raw.githubusercontent.com/ugovi ... er/izsynth -O izsynth && chmod 755 izsynth
As you got access denied I assume you need to run that last command with sudo.
Jos
cd /usr/local/bin
wget https://raw.githubusercontent.com/ugovi ... er/izsynth -O izsynth && chmod 755 izsynth
As you got access denied I assume you need to run that last command with sudo.
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Thanks for your reply Jos,
but I still get the same errors
Jan
but I still get the same errors
Jan
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Vocal announcement - Good Morning Script
you mean access denied, even when using sudo?
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
That is right
using sudo and everything installed but when I want to access izsyntz i get access denied.
Jan
using sudo and everything installed but when I want to access izsyntz i get access denied.
Jan
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Vocal announcement - Good Morning Script
Ok so you got one step further and got the command installed.
Sorry for being persistent but that is even when you use sudo on that command?
Jos
Sorry for being persistent but that is even when you use sudo on that command?
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Yes even on that
and while installing
Code: Select all
pi@raspberrypi ~ $ cd /usr/local/bin
pi@raspberrypi /usr/local/bin $ izsynth
-bash: /usr/local/bin/izsynth: Toegang geweigerd
pi@raspberrypi /usr/local/bin $ sudo izsynth
sudo: izsynth: command not found
pi@raspberrypi /usr/local/bin $
Code: Select all
pi@raspberrypi /usr/local/bin $ sudo wget https://raw.githubusercontent.com/ugoviti/izsynth/master/izsynth -O izsynth && chmod 755 izsynth
--2017-09-15 17:16:01-- https://raw.githubusercontent.com/ugoviti/izsynth/master/izsynth
Herleiden van raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.36.133
Verbinding maken met raw.githubusercontent.com (raw.githubusercontent.com)|151.101.36.133|:443... verbonden.
HTTP-verzoek is verzonden; wachten op antwoord... 200 OK
Lengte: 71866 (70K) [text/plain]
Wordt opgeslagen als: ‘izsynth’
100%[======================================>] 71.866 --.-K/s in 0,02s
2017-09-15 17:16:03 (2,88 MB/s) - '‘izsynth’' opgeslagen [71866/71866]
chmod: veranderen van toegangsrechten van ‘izsynth’: Bewerking niet toegestaan
pi@raspberrypi /usr/local/bin $
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
- jvdz
- Posts: 2189
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Vocal announcement - Good Morning Script
OK, so that means the chmod didn't work and needs to be done with sudo as well.
sudo chmod 755 izsynth
Jos
sudo chmod 755 izsynth
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 497
- Joined: Friday 22 May 2015 12:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11083
- Location: Asten NB Nederland
- Contact:
Re: Vocal announcement - Good Morning Script
Hi Jos,
Thanx, this works!!
Start working on the implementation now...
Again many thnx for your help
Jan
Thanx, this works!!
Code: Select all
pi@raspberrypi /usr/local/bin $ izsynth
izsynth - TTS/Text To Speech synthesizer, background music overlay assembler and audio file converter for PBX and Home Automation Systems
Written by Ugo Viti <[email protected]>
version: 4.8 released: 20170909
usage: /usr/local/bin/izsynth [options]
Option: Argument: Description:
--------------------------------------------------------------------------------
Input/Output file management:
- Synthesize using standard input
-t <text> Text string to synthesize
-i <file or directory> Input txt/wav/mp3 file or directory to synthesize/c onvert (this disable '-t' option)
-o <directory> Output directory to save synthesized and assembled files (current: /dev/shm)
TextToSpeech management:
-e <engine> TTS voice engine (current: naturalreaders)
-v <voice> TTS voice language (current: Peter)
-T <volume> TTS volume (current: none) (use a number from 0.01 to 1)
-L List usable TTS engines
-l List usable TTS voices
Background music management:
-m <file> Input mp3/wav audio file to use as background music
-S <seconds> Start background music after specified time (curren t: 0 sec)
-p <seconds> Pad the begin of the TTS audio using the specified time (current: 5 sec)
-P <seconds> Pad the end of the TTS audio using the specified ti me (current: 5 sec)
-F <seconds> Fade the begin and the end of the wav music using t he specified time (current: 5 sec)
-M <volume> Background music volume (current: none) (use a numb er from 0.01 to 1)
Soundcard audio playback options:
-b Playback the generated files using the soundcard sp eakers (current: yes)
-B Playback in background detaching the izsynth comman d (current: yes) (only if PLAYBACK=yes)
-k Playback command (current: mplayer)
-K Playback command options (current: none)
-d Playback output device (current: default)
-D List available playback output devices
-W <volume> Change the playback soundcard output volume (curren t: none) (use a number from 0 to 100)
-r Remove synthesized file after playback (current: no ) (no = keep the generated high quality audio file for later usage)
Output file options:
-x Export the generated audio file into PBX formats (c urrent: no) (yes = this will assume PLAYBACK=no and OUTPUT_OVERWRITE=yes)
-X Export using the following audio formats (current: "44khz.wav wav gsm ulaw alaw slin") (valid only if EXPORT_AUDIO=yes))
-w Overwrite the synthesized file (current: no)
-s Split destination audio files into audio formats su b directories (current: yes) (valid only if EXPORT_AUDIO=yes)
Misc options:
-C Write/Overwrite the config file using the command a rguments or the default izsynth variables (file: /home/pi/.config/izsynth/izsynt h.conf)
-h Display this help menu
-H Display the 'naturalreaders' TTS Engine help menu
-E Display izsynth usage examples
-V Display izsynth version
Again many thnx for your help
Jan
Your mind is like a parachute,
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
It only works when it is opened!
RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
Who is online
Users browsing this forum: No registered users and 1 guest