Need help integrating with React native

Hi,

I’m trying to integrate and use Spokestack react native sdk but it is not working as expected. The Spokestack “activate” listener is not firing when I say the wake word “Spokestack”. I’m also not getting any error message. I’ve given microphone permission too, but still no luck. Please check the attached code snippet and let me know if something is wrong.

Code snippet

Also is it safe to use Spokestack in production ?

Thank You.

Hi @Ritesh,

Sorry to hear you’re having trouble; thanks for reaching out.

The first thing that stands out to me in your code snippet is that the wake word model URLs are mismatched with the model names:

          wakeword: {
            filter: 'https://s.spokestack.io/u/hgmYb/detect.tflite',
            detect: 'https://s.spokestack.io/u/hgmYb/encode.tflite',
            encode: 'https://s.spokestack.io/u/hgmYb/filter.tflite',
          },

should be

          wakeword: {
            filter: 'https://s.spokestack.io/u/hgmYb/filter.tflite',
            detect: 'https://s.spokestack.io/u/hgmYb/detect.tflite',
            encode: 'https://s.spokestack.io/u/hgmYb/encode.tflite',
          },

That would definitely cause some problems with wake word detection. If you make that change and are still having trouble, post back and we’ll do some more detailed troubleshooting.

Also, a quick note: you included API credentials in your code snippet. You might want to delete those from your account and create new ones.

Use in production

I’m a little unsure what “safe to use” means, but we’ve used Spokestack in several apps distributed via the major app stores. It has a stable API that follows semantic versioning conventions, so you can use that to decide about incorporating new versions.

Hope that helps,
Josh

2 Likes

Hi @josh, thanks for replying.

I tried by fixing the mismatched URLs, but it is still not working. I’m having same issue. There really seems to be some issue. Please check on your end. I’m testing on Android (API level 28).

Wake word detection works fine for me in the React Native sample app, which is the best comparison I can give you without having access to your code.

Here are a few things to try, though:

  • Run the sample app and see if you have the same problem with the wake word there.
  • If so, head back to your app and change the speech pipeline profile to VAD_NATIVE_ASR. If ASR works fine like this, you’ll know it’s a problem with the wake word detection.

If the problem is with wake word, try adding some additional logging. In your call to Spokestack.initialize(), include the property

traceLevel: Spokestack.TraceLevel.PERF,

traceLevel goes inside the config object at the same level as wakeword.
Then, alongside your other event listeners, add

Spokestack.addEventListener('trace', (e) => console.log(e))

I notice that your code snippet already includes a trace listener, but I’m leaving this here in case anyone else comes across this post and doesn’t see your code.

This will give you more details about what’s going on under the hood when you speak. In your case, you’re looking for log messages like
{"message": "SPEECH_PIPELINE wake: 0.912798"}
This represents the wake word detector’s confidence that it’s heard “Spokestack”. The number will likely be lower for you. Try saying “Spokestack”, some other similar sounds, and some dissimilar sounds, and watch the logs. If there’s a recognizable difference in the value when you say “Spokestack” vs. other words, you can set the wakeword.threshold property to a value just under what you’re seeing when you say “Spokestack”. The threshold defaults to 0.5.

It’s worth pointing out, though, that wake word models can’t guarantee 100% accuracy. You’d be the first person to report our default wake word not working at all for them, but your voice might just be different enough from all our training data that the model’s not picking you up properly. If this is the case, we’d love to include your voice in the model if you’re interested in donating a few samples.

Josh