Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picovoice Error (code 00000136) when running cobra on RPI via Node #210

Closed
2 tasks done
y-lobau opened this issue Mar 18, 2024 · 16 comments
Closed
2 tasks done

Picovoice Error (code 00000136) when running cobra on RPI via Node #210

y-lobau opened this issue Mar 18, 2024 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@y-lobau
Copy link

y-lobau commented Mar 18, 2024

Have you checked the docs and existing issues?

  • I have read all of the relevant Picovoice Cobra docs
  • I have searched the existing issues for Cobra

SDK

Node.js

Cobra package version

2.0.0

Framework version

Node v18.19.0

Platform

Raspberry Pi

OS/Browser version

Debian GNU/Linux 12 (bookworm)

Describe the bug

Running the Cobra on the device gives an initialization error.
An API key is correctly set up, and the internet connection and USB microphone suppose to work.

The error I am getting that doesn't make a lot of sense:

/home/rpi/voice-assistant-poc/node_modules/@picovoice/cobra-node/dist/errors.js:76
            throw new CobraIOError(errorMessage, messageStack);
                  ^

CobraIOError: Cobra failed to initialize: 
  [0] Picovoice Error (code `00000136`)
  [1] Picovoice Error (code `00000136`)
    at pvStatusToException (/home/rpi/voice-assistant-poc/node_modules/@picovoice/cobra-node/dist/errors.js:76:19)
    at Cobra.handlePvStatus (/home/rpi/voice-assistant-poc/node_modules/@picovoice/cobra-node/dist/cobra.js:134:46)
    at new Cobra (/home/rpi/voice-assistant-poc/node_modules/@picovoice/cobra-node/dist/cobra.js:59:18)
   ...{
  _message: 'Cobra failed to initialize',
  _messageStack: [
    'Picovoice Error (code `00000136`)',
    'Picovoice Error (code `00000136`)'
  ]
}

Steps To Reproduce

  1. this.cobra = new Cobra(apiKey)
  2. Error

Expected Behavior

The error message gives more details, or the error code is described in Picovoise documentation.

@y-lobau y-lobau added the bug Something isn't working label Mar 18, 2024
@albho
Copy link
Contributor

albho commented Mar 19, 2024

Which Raspberry Pi model are you using? Are you using Debian directly or via the Rpi OS? Are you using 32-bit or 64-bit for Debian?

@y-lobau
Copy link
Author

y-lobau commented Mar 19, 2024

64bit raspberry pi OS installed via pi imager.

@albho
Copy link
Contributor

albho commented Mar 19, 2024

Thanks, and which model are you using?

@y-lobau
Copy link
Author

y-lobau commented Mar 19, 2024

Ah, sorry. It's 3 B.

@albho
Copy link
Contributor

albho commented Mar 20, 2024

I'm not able to reproduce the error on my device. Could you give our Node.js demo a try and confirm that that works on your device?

@y-lobau
Copy link
Author

y-lobau commented Mar 21, 2024

Just tested. It is the same error via the demo:

rpi@rpi:~ $ cobra-mic-demo --access_key <...>
/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/cobra-node/dist/errors.js:76
            throw new CobraIOError(errorMessage, messageStack);
                  ^

CobraIOError: Cobra failed to initialize: 
  [0] Picovoice Error (code `00000136`)
  [1] Picovoice Error (code `00000136`)
    at pvStatusToException (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/cobra-node/dist/errors.js:76:19)
    at Cobra.handlePvStatus (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/cobra-node/dist/cobra.js:134:46)
    at new Cobra (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/cobra-node/dist/cobra.js:59:18)
    at micDemo (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/mic.js:69:24)
    at Object.<anonymous> (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/mic.js:126:1)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
  _message: 'Cobra failed to initialize',
  _messageStack: [
    'Picovoice Error (code `00000136`)',
    'Picovoice Error (code `00000136`)'
  ]
} 
rpi@rpi:~ $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 2: Microphones [Blue Microphones], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The following command records the wav with the input from mic:

arecord -D plughw:2,0 -d 5 test.wav

@albho
Copy link
Contributor

albho commented Mar 21, 2024

Is your device connected to internet while initializing?

@y-lobau
Copy link
Author

y-lobau commented Mar 21, 2024

Yes, It does.
image
Just tried on fresh installation by installing just npm and the demo package. Now, the error is different:

rpi@rpi:~ $ cobra-mic-demo --access_key <...>
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM input
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/pvrecorder-node/dist/errors.js:47
            return new PvRecorderStatusRuntimeError(errorMessage);
                   ^

PvRecorderStatusRuntimeError: PvRecorder failed to initialize.
    at pvRecorderStatusToException (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/pvrecorder-node/dist/errors.js:47:20)
    at new PvRecorder (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/node_modules/@picovoice/pvrecorder-node/dist/pv_recorder.js:47:40)
    at micDemo (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/mic.js:73:20)
    at Object.<anonymous> (/usr/local/lib/node_modules/@picovoice/cobra-node-demo/mic.js:126:1)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
    at Module._load (node:internal/modules/cjs/loader:1013:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
    at node:internal/main/run_main_module:28:49

The recording still working fine with arecord.
What am i missing?

@albho
Copy link
Contributor

albho commented Mar 22, 2024

Ah, I ran the demo using the full RPi OS instead of the Lite - it's possible you're missing a package. We use mini audio to access the recording device. Could you run one of their examples and make sure mini audio is recording properly?

Alternatively, you can also try our file demo instead, which doesn't require any recording device.

@y-lobau
Copy link
Author

y-lobau commented Mar 22, 2024

I didn't find a quick and easy way to check if it is working in their docs. The example page you referenced doesn't make a lot of sense to me honestly. Maybe you could suggest which steps I should perform to validate mini audio.

@albho
Copy link
Contributor

albho commented Mar 22, 2024

Here's how you can run the examples:

  1. clone the miniaudio repo and cd into the examples directory
  2. run the command from their README (either one under Examples. You may have to change some paths based on your file structure.)
  3. run the output file with with the path to an existing audio file on your device. If working, you'll hear the audio being played out of your speakers.

If this doesn't work, it would be helpful if you could try our file demo and see if that works.

@y-lobau
Copy link
Author

y-lobau commented Mar 22, 2024

I was able to play audio file via compiled miniaudio. How it can help though?

@albho
Copy link
Contributor

albho commented Mar 27, 2024

Can you try the simple capture example to see if you can record audio, since that is how PvRecorder will be used?

As well, please also try our file demo so we can see if Cobra can initialize.

@y-lobau
Copy link
Author

y-lobau commented Mar 28, 2024

I just checked the simple capture example. Indeed it seems smth is missing:

rpi@rpi:~/miniaudio/examples/bin $ ./simple_capture test.mp3
ALSA lib pcm.c:2666:(snd_pcm_open_noupdate) Unknown PCM input
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dsnoop.c:566:(snd_pcm_dsnoop_open) unable to open slave
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Press Enter to stop recording...

@albho
Copy link
Contributor

albho commented Mar 28, 2024

Okay, so since it seems like the issue stems from miniaudio, I recommend you check out the miniaudio docs and see if you can get it working on your device.

@laves
Copy link
Member

laves commented Apr 23, 2024

Closing because this seems like an issue with miniaudio/audio recording and not cobra

@laves laves closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants