Dashticz - Function - Playsound/Speak

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

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

Simple text to speak via browser

Post by DewGew »

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 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Dashticz - Function - Playsound/Speak

Post by DewGew »

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 10:01, edited 1 time in total.
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
User avatar
DewGew
Posts: 579
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: Simple text to speak via browser

Post by DewGew »

This fuction is now added to latest beta read at this topic:
viewtopic.php?f=67&t=20426
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
robgeerts
Posts: 1273
Joined: Saturday 24 January 2015 22:12
Target OS: NAS (Synology & others)
Domoticz version: 3.7067
Location: NL
Contact:

Re: Dashticz - Function - playsound/speak

Post by robgeerts »

Works great, in addition:

Remove 'speak' and 'playsound' when you are also using 'speakOn'/'speakOff' and 'playsoundOn'/'playsoundOff'
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by gielie »

Nice work only i can't get the sound to work on my iPad, on my mac it works great tho.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera »

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: 56
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by mAiden88 »

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: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera »

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: 56
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by mAiden88 »

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: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera »

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: 56
Joined: Friday 14 October 2016 22:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.7286
Location: Almelo
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by mAiden88 »

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: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera »

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: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by gielie »

It is a iOs problem i think, Rob doesnt have a iOs device so he cant test it.
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
zodracom
Posts: 11
Joined: Monday 11 February 2019 21:20
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.7900
Location: Roosendaal, Netherlands
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by zodracom »

Vomera wrote: 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
someone has the solution allready? have the same problem :-(
robgeerts
Posts: 1273
Joined: Saturday 24 January 2015 22:12
Target OS: NAS (Synology & others)
Domoticz version: 3.7067
Location: NL
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by robgeerts »

zodracom wrote: Wednesday 06 March 2019 17:49
Vomera wrote: 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
someone has the solution allready? have the same problem :-(
Its a known problem with Kiosk for a long time..
Cant you use chrome for this? (I thought only benefit was fullscreen mode but its possible inside Dashticz now? Or am i missing something?)
Vomera
Posts: 184
Joined: Wednesday 06 September 2017 9:11
Target OS: Linux
Domoticz version:
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by Vomera »

robgeerts wrote: Monday 11 March 2019 22:32
zodracom wrote: Wednesday 06 March 2019 17:49
Vomera wrote: 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
someone has the solution allready? have the same problem :-(
Its a known problem with Kiosk for a long time..
Cant you use chrome for this? (I thought only benefit was fullscreen mode but its possible inside Dashticz now? Or am i missing something?)

I will check this when i'm home. Didnt know there is a full screen mode in dashticz now! I miss that part!
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Dashticz - Function - Playsound/Speak

Post by madpatrick »

Hi,

When ik try to add the script to custom.js, it is not working in my tablet with Fully Remote
On my pc i can hear the message playing.

On the tablet I see the following error

Code: Select all

Error : SpeechsynthesisUtterance is not deficed  Check function getStatus_262 in custom.js line 2206:22
This is the part of custom.js for block 262

Code: Select all

function getStatus_262(block) {
    var Data = block.device.Data;
    var idx = block.idx;
    var device = block.device;

    if (parseFloat(Data) < 1.5) {
        trigger_262 = true;
        block.addClass = 'warning';		// set the addClass parameter for block 262
	speak('Alarm is is  triggered');
    }
    else {
        trigger_262 = false;
        block.addClass = ''; // reset the addClass parameter for block 262
    }
    handleRegen();
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest