So I have this speech to text typing feature that is triggered upon pressing a microphone icon.(因此,我具有语音输入文本功能,该功能是在按下麦克风图标时触发的。)
The feature works.(该功能有效。) My problem is that I want the same icon to do 2 things.(我的问题是我希望同一图标执行2项操作。) 1st click it will start hearing for voice.(第一次单击它将开始听到声音。) 2nd click will stop hearing for voice.(第二次单击将停止听到声音。) I basically want the function onclick
to alternate between 2 functions, Start and Stop.(我基本上希望功能onclick
在两个功能之间交替,即开始和停止。) How do I do it?(我该怎么做?)
Below is what I got currently.(以下是我目前得到的。) That only works to START the recording How do I fit recognition.stop()
into the same click function?(那仅对开始录制有效。如何将recognition.stop()
放入同一单击函数?)
$('#micButton').on('click', function () {
recognition.start(); //this is to start recording
});
Below this is what I thought would work (it doesn't), to alternate between start and stop.(在此之下,我认为可以在开始和停止之间进行切换(不起作用)。)
$('#micButton').on('click',
function () {
recognition.start();
},
function () {
recognition.stop();
}
);
To summarise, how do I get my onclick
to alternate between start and stop?(总而言之,如何让我的onclick
在开始和停止之间切换?)
ask by Coben Yap translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…