From c668b0a59bbba1fc9158dfdc9d571b321633aa71 Mon Sep 17 00:00:00 2001 From: RollingHog <46373241+RollingHog@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:23:52 +0300 Subject: [PATCH] beep on speech end --- index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/index.js b/index.js index 44c1e7f..0d26341 100644 --- a/index.js +++ b/index.js @@ -35,6 +35,16 @@ const textarea = { }, } +function doBeep() { + var context = new window.AudioContext() + var osc = context.createOscillator() // instantiate an oscillator + osc.type = 'sine' // this is the default - also square, sawtooth, triangle + osc.frequency.value = 940 // Hz + osc.connect(context.destination) // connect it to the destination + osc.start() // start the oscillator + osc.stop(context.currentTime + 0.15) +} + var transcript recognition.onresult = function (event) { @@ -62,6 +72,7 @@ recognition.onstart = function () { recognition.onspeechend = function () { // getEl('recog_status').innerText = 'Recognition off' + doBeep() getEl('b_switch_recognition').style.backgroundColor = '' }