Picovoice / porcupine

On-device wake word detection powered by deep learning
https://picovoice.ai/
Apache License 2.0
3.69k stars 496 forks source link

PORCUPINE CASUING ERRORS AND NOT RUNNING TRAINED KEYWORD #1270

Closed MuhammadBilal848 closed 4 months ago

MuhammadBilal848 commented 4 months ago

Have you checked the docs and existing issues?

SDK

Python

Porcupine package version

3.0.2

Framework version

3.12.3

Platform

Windows (x86_64)

OS/Browser version

Chrome - Version 124.0.6367.91 (Official Build) (64-bit)

Describe the bug

I trained a model using porcupine console choosing a language and a wake word, then I downloaded the model and got a .ppn file. I put the file in the folder of keywords where all other wake word files are available.

C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupine\resources\keyword_files\windows

image

When I ran the help using cmd to check if the trained wake word became available, using the command:

porcupine_demo_mic -h

I got this: image

As you can see the wake word file is available "helfen".

When I tried running the file using the command:

porcupine_demo_mic --access_key MY_API --keywords helfen

I am getting this error:

One or more arguments provided to Porcupine is invalid:  Namespace(access_key='My_API', keywords=['helfen'], keyword_paths=None, library_path=None, model_path=None, sensitivities=[0.5], audio_device_index=-1, output_path=None, show_audio_devices=False)
Initialization failed:
  [0] Keyword file (.ppn) file has incorrect format or belongs to a different platform.
  [1] Picovoice Error (code `00000136`)
  [2] Loading keyword file at `C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupine\resources/keyword_files\windows\helfen_windows.ppn` failed with `INVALID_ARGUME
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\Scripts\porcupine_demo_mic.exe\__main__.py", line 7, in <module>
  File "C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupinedemo\porcupine_demo_mic.py", line 97, in main
    raise e
  File "C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupinedemo\porcupine_demo_mic.py", line 88, in main
    porcupine = pvporcupine.create(
                ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupine\_factory.py", line 69, in create
    return Porcupine(
           ^^^^^^^^^^
  File "C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupine\_porcupine.py", line 198, in __init__
    raise self._PICOVOICE_STATUS_TO_EXCEPTION[status](
pvporcupine._porcupine.PorcupineInvalidArgumentError: Initialization failed:
  [0] Keyword file (.ppn) file has incorrect format or belongs to a different platform.
  [1] Picovoice Error (code `00000136`)
  [2] Loading keyword file at `C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupine\resources/keyword_files\windows\helfen_windows.ppn` failed with `INVALID_ARGUME

How can I resolve this?

Steps To Reproduce

I do not know.

Expected Behavior

The code should run the model and be able to detect the word "Helfen"

MuhammadBilal848 commented 4 months ago

I solved it.

When I trained the model, I accidentally downloaded it in the Android build and was running it on Windows. I trained the model again and downloaded it in the Windows build. Then, I ran this command::

porcupine_demo_mic --access_key MY_API --keywords helfen

Then came another error (🤣):

[0] Keyword file (.ppn) and model file (.pv) should belong to the same language. File belongs todewhile model file (.pv) belongs toen.

This is the language model error, so I downloaded the correct language model from here and put it inside "common" folder created by porcupine. and I added model_path arg in the next command and voilaaaa it worked.

The final command was this:

porcupine_demo_mic --access_key MY_API --keywords helfen --model_path 'C:\Users\Bilal\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pvporcupine\lib\common'