question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Commands don't work of languages with non-english characters

See original GitHub issue

So the speech recognition does support for instance, hebrew, however when trying to write a command in hebrew, the callback isn’t summoned. according to the transcript, it was spoken perfectly, but it did not activate the command callback that was set up. Also, resetTranscript does not work when called by handleReset (or perhaphs it’s just not called), only with the spoken ‘clear’ command

 const { resetTranscript } = useSpeechRecognition()
  const commands = [
    {
      command: 'clear',
      callback: ({ resetTranscript }) => resetTranscript()
    },
    {
      command: ['Everything is working','Nothing is working','Just the audio works','Just the video works','שלום'],
      callback: (command, spokenPhrase ) => {
      sendAns(spokenPhrase)
        handleReset();
    },
      isFuzzyMatch: true,
      fuzzyMatchingThreshold: 0.2},
  ]

  const { transcript } = useSpeechRecognition({ commands })
  const handleReset = useCallback(() => {
      SpeechRecognition.stopListening()
      SpeechRecognition.startListening({
        continuous:true, 
        language: 'he'
      })
  },[]);
  if (!SpeechRecognition.browserSupportsSpeechRecognition()) {
    return null
  }else{
    SpeechRecognition.startListening({
      continuous:true, 
      language: 'he'
    });
  }

for reference, the sendAns command sends the spoken phrase back to the parent

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Nitzahoncommented, Jan 18, 2021

I found a solution that appears to work! I connected my webcam stream to hark and had it set a redux boolean on the speaking and stopped_speaking events. then I added this useEffect:

 useEffect(() => {
    if(isRecog && !listening){
      SpeechRecognition.startListening({
        language: language
      });
    }
    else if(!isRecog && listening){
      SpeechRecognition.stopListening();
    }
  }, [isRecog,listening,language])

isRecog is a selector from redux signaling a request to record. All I need now is to make sure it doesn’t interfere with the media recorder I have set up, but I think this is a great solution for anyone looking to activate speech recognition when the user speaks.

0reactions
Nitzahoncommented, Nov 29, 2020

I’ll probably change my code then, to manually start the listen on a function call. but I will also need to recognize when listening has stopped.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't type non-english characters in terminal
I use gnome desktop with Debian and wayland on my laptop, so I use command-line tools and 'gnome-settings' program. You might need the...
Read more >
CMD: How to use non-English characters? - Super User
Start CMD with CMD /u to cause CMD to redirect to files in UTF-16, Little Endian. Windows distinguishes between showed up text and...
Read more >
How to print a variable having non-English characters to the ...
Open the "Command Prompt" properties and make sure to select one of the new fonts that should appear to support your language.
Read more >
Non-English-based programming languages - Wikipedia
Non -English-based programming languages are programming languages that do not use keywords taken from or inspired by English vocabulary.
Read more >
Sending Special Character for non-English languages
Hello Everyone :D , I am trying to send strings in a field using AHK script. The string has some characters that is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found