How to Interrupt/ Stop Session

Hallo,

I connected rhasspy with node red via websocket.
In node red I build my “skills”.

I am now creating a timer/alarm clock.
At the end my flow is playing a alarm clock sound. I would like to send a stop intent to stop/interrupt the sound. But when my raspberry is playing the sound it isn’t listen to me and did not recognise the wake word.
I use porcupine for wakeword detection.

Has anybody an idea how to handle this?

Cheers Becks89

What microphone do you use? Does it have acoustic echo cancellation?

If it does not (which seems to be the case), look on this forum for « AEC » and « acoustic echo cancellation » to learn more.

Hope this helps.

Thank you for your answer.

It is a good hint.
I have the Seeed Studio ReSpeaker 4-Mic Array for Raspberry Pi microphone.

I will give this ec https://github.com/voice-engine/ec a try.

Or do you have a better idea?

It’s either PulseAudio AEC module or Seeed VoiceEngine EC software.

Could you share your node-red flow for the alarm/timer? I am looking for something similar.

kind regards,
Hugo

Sure,

here it is:

[{"id":"791afdc9.4b2af4","type":"tab","label":"SetTimer","disabled":false,"info":""},{"id":"cb1d5361.2bcd78","type":"link in","z":"791afdc9.4b2af4","name":"In SetTimer","links":["3018c667.da305a"],"x":495,"y":360,"wires":[["922d240f.c6deb"]]},{"id":"16bb36dd.878ec9","type":"debug","z":"791afdc9.4b2af4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1650,"y":660,"wires":[]},{"id":"bc61e2b1.20f7","type":"link out","z":"791afdc9.4b2af4","name":"OUT SetTimer","links":["2d954d4.375c2b2"],"x":1715,"y":600,"wires":[]},{"id":"a3dab5e9.572b6","type":"mytimeout","z":"791afdc9.4b2af4","name":"Timer","outtopic":"","outsafe":"","outwarning":"","outunsafe":"off","warning":"0","timer":"7","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":940,"y":460,"wires":[["eaa1c139.7da9e","6af44557.a07784"],["bb4e5ced.c6cfc"]]},{"id":"922d240f.c6deb","type":"function","z":"791afdc9.4b2af4","name":"","func":"var minutes;\nvar seconds;\nvar hours;\n\nif(typeof msg.slots.time_hours !== 'undefined') {\n    hours = msg.slots.time_hours;\n} else {\n    hours=0;\n}\n\nif(typeof msg.slots.time_seconds !== 'undefined') {\n    seconds = msg.slots.time_seconds;\n} else {\n    seconds=0;\n}\n\n\nif(typeof msg.slots.time_minutes !== 'undefined') {\n    minutes=msg.slots.time_minutes;\n} else {\n    minutes=0;\n}\n\n\nvar time = hours*3600+minutes*60+seconds;\nmsg.payload = \"on\";\nmsg = {payload:msg.payload,timeout:time};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":460,"wires":[["a3dab5e9.572b6"]]},{"id":"ccb33c94.0274c","type":"inject","z":"791afdc9.4b2af4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"str","x":470,"y":240,"wires":[["a3dab5e9.572b6"]]},{"id":"6af44557.a07784","type":"switch","z":"791afdc9.4b2af4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"off","vt":"str"},{"t":"eq","v":"stop","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1110,"y":460,"wires":[["958eabfb.c4ca4"],["4deda2f9.cbee9c"]]},{"id":"958eabfb.c4ca4","type":"template","z":"791afdc9.4b2af4","name":"Build Answer","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\"Der Taimer ist fertig\"","output":"json","x":1290,"y":460,"wires":[["bc61e2b1.20f7"]]},{"id":"77bffcd5.60e79c","type":"debug","z":"791afdc9.4b2af4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1490,"y":140,"wires":[]},{"id":"8373d618.dfb56","type":"link in","z":"791afdc9.4b2af4","name":"In Stop Timer","links":["8a0a53da.6146e"],"x":495,"y":200,"wires":[["b11f3bd1.6df4"]]},{"id":"b11f3bd1.6df4","type":"function","z":"791afdc9.4b2af4","name":"","func":"msg.payload = \"stop\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":940,"y":200,"wires":[["eaa1c139.7da9e"]]},{"id":"eaa1c139.7da9e","type":"PlaySound","z":"791afdc9.4b2af4","name":"","playerOptions":"{}","audioURI":"/home/pi/Sounds/Alarm-ringtone.mp3","options":"{\"afplay\": [ \"-r\", 0.5, \"-t\", 2.5, \"-v\", 1 ], \"mplayer\": [ \"-volume\", 1 ] }","x":1550,"y":200,"wires":[[]]},{"id":"188a8538.84f89b","type":"link in","z":"791afdc9.4b2af4","name":"Link von GetTimer zu SetTimer","links":["6ebd065b.d5d9d8"],"x":495,"y":620,"wires":[["dd3966d1.6d84b"]]},{"id":"bb4e5ced.c6cfc","type":"function","z":"791afdc9.4b2af4","name":"","func":"// Hours\nvar Hours = ((msg.payload)/3600);\nHours = Math.floor(Hours);\n\n// Minutes\nvar Minutes = (msg.payload-(Hours*3600))/60;\nMinutes = Math.floor(Minutes);\n\n// Seconds\nSeconds = (msg.payload-(Hours*3600)-(Minutes*60));\n\nmsg={timer_min:Minutes,timer_sec:Seconds}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1040,"y":560,"wires":[["a9e21055.bd3918"]]},{"id":"a9e21055.bd3918","type":"gate","z":"791afdc9.4b2af4","name":"Gate 1","controlTopic":"control","defaultState":"closed","openCmd":"1","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":true,"x":1260,"y":680,"wires":[["ab08c533.dc8f4"]]},{"id":"3a649a44.b70516","type":"inject","z":"791afdc9.4b2af4","name":"","props":[{"p":"payload","v":"1","vt":"str"},{"p":"topic","v":"control","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"1","payloadType":"str","x":440,"y":700,"wires":[["a9e21055.bd3918","7c76d6a6.734a7"]]},{"id":"cee7e929.b35a68","type":"delay","z":"791afdc9.4b2af4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1020,"y":740,"wires":[["a9e21055.bd3918"]]},{"id":"7c76d6a6.734a7","type":"function","z":"791afdc9.4b2af4","name":"","func":"msg={payload:\"close\",topic:\"control\"};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":850,"y":740,"wires":[["cee7e929.b35a68"]]},{"id":"dd3966d1.6d84b","type":"function","z":"791afdc9.4b2af4","name":"","func":"msg={payload:\"1\",topic:\"control\"};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":620,"wires":[["a9e21055.bd3918","7c76d6a6.734a7"]]},{"id":"ab08c533.dc8f4","type":"function","z":"791afdc9.4b2af4","name":"","func":"Satz=\"Es sind noch\" + msg.timer_min + \"Minuten auf dem Taimer\";\nmsg={payload:Satz}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1460,"y":660,"wires":[["16bb36dd.878ec9","bc61e2b1.20f7"]]},{"id":"82cc7eb6.7f9398","type":"comment","z":"791afdc9.4b2af4","name":"STT Not Working","info":"Stop is not working. Missing AEC","x":400,"y":200,"wires":[]},{"id":"42d92605.01f61","type":"comment","z":"791afdc9.4b2af4","name":"Set Timer","info":"","x":400,"y":380,"wires":[]},{"id":"167782f2.b81ab5","type":"inject","z":"791afdc9.4b2af4","name":"set timer 5minutes","props":[{"p":"slots.time_hours","v":"0","vt":"num"},{"p":"slots.time_minutes","v":"5","vt":"num"},{"p":"slots.time_seconds","v":"0","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":430,"y":420,"wires":[["922d240f.c6deb"]]},{"id":"fbf042e9.0eea7","type":"comment","z":"791afdc9.4b2af4","name":"Back to Rhasspy","info":"","x":1790,"y":560,"wires":[]},{"id":"4deda2f9.cbee9c","type":"template","z":"791afdc9.4b2af4","name":"Build Answer","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"\"Der Taimer wurde beendet\"","output":"json","x":1290,"y":500,"wires":[["bc61e2b1.20f7"]]}]    

it is very basic programming. I would appreciate any feedback.

Cheers Becks89

1 Like

I was looking to do something similar, and recently posted about it.

I just stumbled across this thread and was wondering if you used an alarm sound file that looped, and if you were able to get the interrupt to work.