# Speaking clock with Rhasspy

**URL:** <https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651>\
**Category:** General\
**Created:** [27 November 2020 21:28 UTC](https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651 "2020-11-27T21:28:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![9cirrus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9cirrus/32/32737_2.png) [@9cirrus](https://discourse.nodered.org/u/9cirrus)\
**Post date:** [27 November 2020 21:28 UTC](https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651/1 "2020-11-27T21:28:51Z")

</div>

Good evening to all.

I am home automation user and I discover node red through rhasspy.  
I am also a beginner in java script.

For several weeks I have looking for a proper syntax java script to speech the current time.  
In the rhasspy voice assistant my intent is [GetTime] and i’d like to hear the current time when i say 'what time is it ?' ( of course in french).

I copied a code template into a tutorial.  
Here my code in a node 'Function' who is working (i hear the voice) well with string value example 18(hh) and 45(mn) or other string value :

msg.payload = "{"speech":{"text":"Il est 18 heures et 45 minutes "},"site\_id":"" + msg.payload.site\_id + ""}"  
return msg;

I found this code below :

var aujourdhui = new Date();  
var heure = aujourdhui.getHours();  
var minutes = aujourdhui.getMinutes();  
var secondes = aujourdhui.getSeconds();

I guess i have to replace 18 and 45 by a 'msg.payload' value but i have syntax errors.

what is the right syntax to replace string time value (18 and 45) to the current time ?

Can you help me, please ?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 November 2020 23:03 UTC](https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651/2 "2020-11-27T23:03:42Z")

</div>

Try something like this

```auto
var aujourdhui = new Date();
var heure = aujourdhui.getHours();
var minutes = aujourdhui.getMinutes();
msg.payload = {"speech":{"text":"Il est " + heure + " heures et " + minutes + " minutes "},"site_id": msg.payload.site_id };
return msg;

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 November 2020 02:12 UTC](https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651/3 "2020-11-28T02:12:07Z")

</div>

> [@E1cid](#):
>
> `"Il est " + heure + " heures et " + minutes + " minutes "`

Instead of that, you could use the neater:

```auto
`Il est ${heure} heures et ${minutes} minutes `

```

Note the back-ticks instead of quotes.

---

<div class="post-metadata">

**Author:** ![9cirrus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/9cirrus/32/32737_2.png) [@9cirrus](https://discourse.nodered.org/u/9cirrus)\
**Post date:** [28 November 2020 08:38 UTC](https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651/4 "2020-11-28T08:38:09Z")

</div>

For this to work I only had to remove the json node after the function node.  
It is fine now.  
THANK YOU very much. 😀

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 January 2021 08:38 UTC](https://discourse.nodered.org/t/speaking-clock-with-rhasspy/36651/5 "2021-01-27T08:38:38Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
