Page 1 of 1

JS Speech Recognition in Spider

Posted: Mon Oct 05, 2020 4:44 pm
by LogicGord
Hello,
I am looking for a solution.
The function as JavaScript in the HTML code works very well.
Now I wanted to do it with SpiderBasic.
I will probably get the answer, asyncron, from the JavaScript page.
I start this procedure with a button.
I hang on to this point.
Sorry for my English.

Code: Select all


Global transcript.s 

Procedure CloseWindowEvent()
  CloseWindow(EventWindow())
EndProcedure


Procedure SpeechRecognition()
  
    ;*** new speech recognition object ***
    ! var SpeechRecognition = SpeechRecognition  || webkitSpeechRecognition;
    ! var recognition = new SpeechRecognition();
    
    ;*** This runs when the speech recognition service returns result ***
    ! recognition.onresult = function(event) {
    !    var v_transcript = event.results[0][0].transcript;
    ! };

    ;*** start recognition ***
    ! recognition.start();
    
    SetGadgetText(#tg_speech_result_text, transcript)
    
EndProcedure


Re: JS Speech Recognition in Spider

Posted: Mon Oct 05, 2020 9:20 pm
by Peter
not tested, but it should work if you remove the 'var' in front of v_transcript.

instead of:

Code: Select all

! var v_transcript = event.results[0][0].transcript;
try this:

Code: Select all

!  v_transcript = event.results[0][0].transcript;

Re: JS Speech Recognition in Spider

Posted: Tue Oct 06, 2020 3:19 am
by LogicGord
Thank you, it works.