Picovoice / web-voice-processor

A library for real-time voice processing in web browsers
https://picovoice.ai/
Apache License 2.0
200 stars 19 forks source link

TypeError: Cannot read properties of undefined (reading 'trim') #15

Closed johnbowdenatfacet closed 2 years ago

johnbowdenatfacet commented 2 years ago

hi,

I've been trying to integrate with a web app, and have been getting: TypeError: Cannot read properties of undefined (reading 'trim')

tried with a fresh create react app and coppied the component from: https://picovoice.ai/docs/api/picovoice-react/

Demo repo here https://github.com/johnbowdenatfacet/pico2

Am I missing something?

Thank you

kenarsa commented 2 years ago

Can you please give it another go? The docs on our website were out-of-date for a few days after v2.0 release

johnbowdenatfacet commented 2 years ago

Can you please give it another go? The docs on our website were out-of-date for a few days after v2.0 release

Thanks @kenarsa I now have it working in the fresh CRA project, though in our application I'm getting the following: 'pv_porcupine_init' failed with status ACTIVATION_ERROR

Same code, same rhino/porcupine base64 in both apps. Any ideas as to this error?

ErisMik commented 2 years ago

If it's the exact same code, most likely then the issue is that you are missing the accessKey field in the picovoiceHookArgs parameter in the usePicovoice hook. This was a breaking change in v2.0 that you may have got caught in the middle of.

You will need to:

  1. Login or signup for a free account on the Picovoice Console.
  2. Go to the AccessKey tab to create one or use an existing AccessKey.
  3. Use that AccessKey as an input to the usePicovoice hook.

Give it another go with the AccessKey and let me know if that resolves your issue.


The same page you linked earlier now contains an API reference laying out exactly what inputs and types are required for the usePicovoice hook.

This page contains a quick getting started guide that provides some example code updated to v2.0 that might give you some support as well.

johnbowdenatfacet commented 2 years ago

@ErisMik this is what I have in both apps, working in the fresh CRA, not in our application: const { isLoaded, // isListening, isError, // errorMessage, // start, // resume, // pause, engine, errorMessage } = usePicovoice( PicovoiceWorkerFactory, { accessKey:ACCESS_KEY, // "Picovoice" is one of the builtin wake words, so we merely need to ask for it by name. // To use a custom wake word, you supply the .ppn files in base64 and provide a label for it. // porcupineKeyword: 'Picovoice', porcupineKeyword: [{ base64: ONE_OH_ONE_64, custom: 'hi' }], rhinoContext: { base64: RHN_CONTEXT_BASE64 }, start: true }, keywordEventHandler, inferenceEventHandler );

ErisMik commented 2 years ago

Is anything else printed to the developer console in your failing application?

johnbowdenatfacet commented 2 years ago

@ErisMik had to allow in our content security policy. Though now I'm getting: 'pv_porcupine_init' failed with status ACTIVATION_LIMIT_REACHED

ErisMik commented 2 years ago

Unfortunately that means you've hit the activation limits of your account as set. If you are an existing commercial user, please reach out to your contact at Picovoice to resolve this. If you are interested in becoming a commercial user, contact sales. Otherwise, you can wait 30 days for the usage limits to reset.

eoghanatfacet commented 2 years ago

@ErisMik & @kenarsa I've sent a separate email to Ian as our tech support contact at Picovoice referencing this issue as I think the activation limit is due to regenerating around the V1.9-V2.0 siwtchover on Nov 25/26. We are a commercial user on a developer license

kenarsa commented 2 years ago

Got it! closing this and will circle back over the email shortly.