JS Speech Recognition in Spider

Using Javascript from SpiderBasic
LogicGord
Posts: 2
Joined: Mon Oct 05, 2020 4:22 pm

JS Speech Recognition in Spider

Post 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

User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: JS Speech Recognition in Spider

Post 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;
LogicGord
Posts: 2
Joined: Mon Oct 05, 2020 4:22 pm

Re: JS Speech Recognition in Spider

Post by LogicGord »

Thank you, it works.
Post Reply