Dashticz - Function - Playsound/Speak

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: robgeerts, htilburgs

Post Reply
User avatar
DewGew
Posts: 263
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi
Domoticz version: V4.9741
Location: Sweden
Contact:

Simple text to speak via browser

Post by DewGew » Wednesday 15 November 2017 17:00

This is a simple text to speak using Speech Synthesis API to make your browser speak. I had to use the variables onCalled and offCalled for the speak to run once else it starts over again and again and....maybe someone have simpler way to do this.

Put this codes in custom.js:

Speech function:

Code: Select all

// Speech function 
function speak(textToSpeak) {
   var newUtterance = new SpeechSynthesisUtterance();
   newUtterance.text = textToSpeak;
   newUtterance.lang = 'en-GB'; // change to your langage if its supported (nl-NL, en-GB, de-DE, etc)
   window.speechSynthesis.speak(newUtterance);
}
Device:

Code: Select all

// Devices that run speak function
// change 136 to your idx
var onCalled_136 = false
var offCalled_136 = false
function getStatus_136(idx,value,device){
	if(device['Data']=='On'){
		offCalled_136 = false
		if(!onCalled_136){
			speak('Device is on');
			onCalled_136 = true
		}
	}
	else{
		onCalled_136 = false
		if(!offCalled_136){
			speak('Device is off');
			offCalled_136 = true
		}
	}
}
Raspberry Pi 2B - domoticz - Aeon Labs Z-Stick GEN5 - RFlink gateway
NanoPi NEO-air - domoticz - REGO6XX interface
Dashticz V2 - Homebridge

User avatar
DewGew
Posts: 263
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi
Domoticz version: V4.9741
Location: Sweden
Contact:

Dashticz - Function - Playsound/Speak

Post by DewGew » Thursday 16 November 2017 11:40

New functions for playsound and speak is added in latest Beta.
Speak works only in english female voice at the moment.

How to use:

Code: Select all

blocks[123]['playsoundOn'] = 'sounds/airplane.mp3'; //only when turn on
blocks[123]['playsoundOff'] = 'sounds/ping.mp3'; //only when turn off

Code: Select all

blocks[123]['speakOn'] = 'Device is on';
blocks[123]['speakOff'] = 'Device is off';

Code: Select all

blocks[123]['playsound'] = 'sounds/button_click.mp3' //toggle
blocks[123]['speak'] = 'Device has toggled';
Last edited by DewGew on Friday 17 November 2017 11:01, edited 1 time in total.
Raspberry Pi 2B - domoticz - Aeon Labs Z-Stick GEN5 - RFlink gateway
NanoPi NEO-air - domoticz - REGO6XX interface
Dashticz V2 - Homebridge

User avatar
DewGew
Posts: 263
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi
Domoticz version: V4.9741
Location: Sweden
Contact:

Re: Simple text to speak via browser

Post by DewGew » Thursday 16 November 2017 12:03

This fuction is now added to latest beta read at this topic:
viewtopic.php?f=67&t=20426
Raspberry Pi 2B - domoticz - Aeon Labs Z-Stick GEN5 - RFlink gateway
NanoPi NEO-air - domoticz - REGO6XX interface
Dashticz V2 - Homebridge

User avatar
robgeerts
Posts: 1247
Joined: Saturday 24 January 2015 23:12
Target OS: NAS (Synology & others)
Domoticz version: 3.7067
Location: NL
Contact:

Re: Dashticz - Function - playsound/speak

Post by robgeerts » Thursday 16 November 2017 19:38

Works great, in addition:

Remove 'speak' and 'playsound' when you are also using 'speakOn'/'speakOff' and 'playsoundOn'/'playsoundOff'
Creator of Dashticz
Do you appreciate my work and want to buy me a beer?
Send:
- XVG to D8fwNbyV6YxJk1aSiXftWTtdaPipsKn2Fa
- ANY ERC20-TOKEN to 0x9b8ee84329d77765a28bca188218c6c793875a8a

or donate via PayPal: https://www.paypal.me/robgeerts

User avatar
gielie
Posts: 236
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by gielie » Monday 20 November 2017 15:57

Nice work only i can't get the sound to work on my iPad, on my mac it works great tho.
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

Vomera
Posts: 33
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera » Thursday 10 May 2018 13:24

Hi,

I’m using dashticz on my android tablet (Samsung tab a).
When I open dashticz on the Samsung browser I can get sounds when I change a button. Device is turned on or off. But when I use fully kiosk browser it doesn’t work. Is this a bug in dashticz or the fully kiosk browser? How can I solve the problem?

edit: speak function doesnt work, mp3 sounds works

User avatar
mAiden88
Posts: 58
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by mAiden88 » Thursday 10 May 2018 14:07

I got little bit the same issue.. On my desktop it works perfect, on my ipad i dont get any sound or speak.
Anyone can build a fast processor. The trick is to build a fast system.

Vomera
Posts: 33
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera » Friday 11 May 2018 13:11

mAiden88 wrote:
Thursday 10 May 2018 14:07
I got little bit the same issue.. On my desktop it works perfect, on my ipad i dont get any sound or speak.
Also on other browsers ?

User avatar
mAiden88
Posts: 58
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by mAiden88 » Friday 11 May 2018 13:14

Vomera wrote:
Friday 11 May 2018 13:11
mAiden88 wrote:
Thursday 10 May 2018 14:07
I got little bit the same issue.. On my desktop it works perfect, on my ipad i dont get any sound or speak.
Also on other browsers ?
I try:

Safari
Chrome
Firefox

On My Windows desktop i use Chrome.
Anyone can build a fast processor. The trick is to build a fast system.

Vomera
Posts: 33
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera » Friday 11 May 2018 13:31

At the moment i use only the mp3 options, as workaround that works for me.

I tried it on my iphone on safari, it works.
Is your sound turned on ?
Volume up to 100%?
Do not disturb off ?

What ios version do you have ?

User avatar
mAiden88
Posts: 58
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by mAiden88 » Friday 11 May 2018 18:32

Vomera wrote:
Friday 11 May 2018 13:31
At the moment i use only the mp3 options, as workaround that works for me.

I tried it on my iphone on safari, it works.
Is your sound turned on ?
Volume up to 100%?
Do not disturb off ?

What ios version do you have ?
Let me introduce myself first .. I am certificated in ICT.
Now follow an education to application developer
Yes my sound are on and on 100%.
Do not disturb off is not set.
I have iOS version 11.3
Anyone can build a fast processor. The trick is to build a fast system.

Vomera
Posts: 33
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera » Sunday 13 May 2018 13:52

Tnx for the introduction so then you know what you are doing :)
Correction i tried it again on iphone and ipad and it doesnt work anymore :/ strange.

when i switch a button with sound on my iphone the samsung tablet works fine but iphone will not respond.
(i have a samsung tablet on my wall)

User avatar
gielie
Posts: 236
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by gielie » Monday 04 June 2018 15:04

It is a iOs problem i think, Rob doesnt have a iOs device so he cant test it.
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests