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

Porcupine throws runtime error on running #617

Closed
OnlinePage opened this issue Jan 11, 2022 · 15 comments
Closed

Porcupine throws runtime error on running #617

OnlinePage opened this issue Jan 11, 2022 · 15 comments
Assignees

Comments

@OnlinePage
Copy link

OnlinePage commented Jan 11, 2022

Hi, I have been trying to use porcupine in python with pvpocrupine on PyPI, with a very basic example of instantiating the porcupine object with access_key and keywords, it throws an unknown runtime error.
Here is the code.

import pvporcupine 

# access_key = "${ACCESS_KEY}" # AccessKey obtained from Picovoice Console (https://picovoice.ai/console/)

handle = pvporcupine.create(access_key="/6JE6BtRaWEQ8Y7DMhTXW5pUGXp9+WtA==", keywords=['porcupine'])
#above access key is altered for security reason

this throws below error

  Traceback (most recent call last):

  File "c:\Users\Pranshu Ranjan\s2\actions\pic_again.py", line 43, in <module>

  handle = pvporcupine.create(access_key="/6JEWV7IWygsvGC0n9LSHQH60G6BtRaWEQ8Y7DMhTXW5pUGXp9+WtA==", 
  keywords=['porcupine'])
  File "C:\ProgramData\Anaconda3\lib\site-packages\pvporcupine\__init__.py", line 77, in create
  return Porcupine(
  File "C:\ProgramData\Anaconda3\lib\site-packages\pvporcupine\porcupine.py", line 158, in __init__
  raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
  pvporcupine.porcupine.PorcupineRuntimeError

system spec:-

  • anaconda environment
  • Windows 11 64 bit
  • Python 3..6.6
  • pvporcupine 2.0.4

Earlier with pvporcupine 1.9.0, it runs flawlessly great.
Please let me know the possible fix to the above issue.

@kenarsa
Copy link
Member

kenarsa commented Jan 11, 2022

the same document clearly asks you to keep your AccessKey secret:

The Porcupine SDK requires a valid AccessKey at initialization. AccessKeys act as your credentials when using Porcupine SDKs. You can create your AccessKey for free. Make sure to keep your AccessKey secret.

@kenarsa
Copy link
Member

kenarsa commented Jan 11, 2022

do you have internet connectivity? you do need to have connectivity to verify your AccessKey

@OnlinePage
Copy link
Author

the same document clearly asks you to keep your AccessKey secret:

The Porcupine SDK requires a valid AccessKey at initialization. AccessKeys act as your credentials when using Porcupine SDKs. You can create your AccessKey for free. Make sure to keep your AccessKey secret.

ya my bad I altered it now!

@OnlinePage
Copy link
Author

OnlinePage commented Jan 11, 2022

do you have internet connectivity? you do need to have connectivity to verify your AccessKey

yes, internet connectivity is available, I am making it sure with the below code.

import requests
import pvporcupine
url = "http://www.google.com"
timeout = 5
try:
    request = requests.get(url, timeout=timeout)
    print("Connected to the Internet")
    handle = pvporcupine.create(access_key="/6JEWV7IWygsvY7DMhTXW5pUGXp9+WtA==", keywords=['porcupine'])
    #altered access key for security reason

except (requests.ConnectionError, requests.Timeout) as exception:
    print("No internet connection.")

and here is the output of the above.

Connected to the Internet
Traceback (most recent call last):
File "c:/Users/Pranshu Ranjan/sam_2/actions/pic_again.py", line 47, in <module>
    handle = pvporcupine.create(access_key="/6JEWV7IWygsvGC0n9LSHQH60G6BtRaWEQ8Y7DMhTXW5pUGXp9+WtA==", keywords=['porcupine'])
File "C:\Users\Pranshu Ranjan\.conda\envs\sam_env\lib\site-packages\pvporcupine\__init__.py", line 82, in create
    sensitivities=sensitivities)
File "C:\Users\Pranshu Ranjan\.conda\envs\sam_env\lib\site-packages\pvporcupine\porcupine.py", line 158, in __init__
    raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
pvporcupine.porcupine.PorcupineRuntimeError

@OnlinePage
Copy link
Author

do you have internet connectivity? you do need to have connectivity to verify your AccessKey

Just waiting to know any possible fix for it!!

@kenarsa
Copy link
Member

kenarsa commented Jan 14, 2022

Can you also install porcupine via PIP (not Conda) and verify you can reproduce it?

@kenarsa kenarsa self-assigned this Jan 14, 2022
@OnlinePage
Copy link
Author

OnlinePage commented Jan 14, 2022

Can you also install porcupine via PIP (not Conda) and verify you can reproduce it?

As u said I did install porcupine outside conda on windows, but the issue is the same, below is the screenshot of what I did.
image

You can clearly see, this time I have installed porcupine without conda in the terminal and the following the basic instantiating the object of a porcupine. Please, any fix?

@laves laves self-assigned this Jan 14, 2022
@laves
Copy link
Member

laves commented Jan 14, 2022

@OnlinePage we're going to look into this. Thanks for your patience.

@laves
Copy link
Member

laves commented Jan 14, 2022

@OnlinePage we are unable to reproduce this issue on a Windows 11 machine. The only thing that we can think of here is that you may have a non-standard environment variable set up. To check that, can you open Powershell and input the following two commands:

echo $env:userprofile
echo $env:homedrive$env:homepath

One of these commands should print the value to your home user directory. If not, then that would cause the error.

@OnlinePage
Copy link
Author

@OnlinePage we are unable to reproduce this issue on a Windows 11 machine. The only thing that we can think of here is that you may have a non-standard environment variable set up. To check that, can you open Powershell and input the following two commands:

echo $env:userprofile
echo $env:homedrive$env:homepath

One of these commands should print the value to your home user directory. If not, then that would cause the error.

Thanks again for your reply! I tried running the above command in windows Powershell, below is the screenshot of it.
image

You can see I am getting the home user directory as the output on both commands, still confused why it's not working 😣.
Whereas with porcupine version 1.9, it's running flawlessly great. Please, any workaround?

@laves
Copy link
Member

laves commented Jan 17, 2022

Okay, thank you - that disproves our original hunch. Unfortunately, since we can't reproduce this issue with the same setup, we can only ask you to perform some more diagnostic steps in order to narrow down the problem with your specific environment. Could you try turning off your internet and initializing Porcupine? If you get the same error, that will tell us a bit about where the error is being produced.

@OnlinePage
Copy link
Author

Thanks again for incorporating so far, so I did as you said. I pulled off ethernet and tried running the same code, this time I got a different error. You can see the below screenshot for clarity.
image

@kenarsa kenarsa removed their assignment Jan 17, 2022
@OnlinePage
Copy link
Author

@OnlinePage - we're pretty sure we now know what is causing this and will be addressing it in our next release. For now, a workaround for you would be to either remove/move the profile.ps1 file located in your Documents/WindowsPowerShell folder or to enable the running of Powershell scripts on your system by opening Powershell as an administrator and running the following command:

Set-ExecutionPolicy RemoteSigned

That should also remove that large bit of red text you get when you open your Powershell.

Yeah I did run that command and enable the execution policies and now those red warnings are no more and bingo, the script is now running great!! 😎😀.
image

So I guess picovoice runs a PowerShell script in the backend since it was disabled that's why it was causing an error? can you just explain a little about it? Well, thanks again @laves and Picovoice team for working and finding the cause of the issue!! I hope you guys will mention and fix such scenarios in upcoming updates.

@laves
Copy link
Member

laves commented Jan 18, 2022

Great! I won't get into any specifics, but we don't run any Powershell script files. That block of error text however was making its way into a system call we use. We'll be applying a permanent fix for this in the next release so that this should not effect future users. Thanks for bringing this to our attention!

@laves laves closed this as completed Jan 18, 2022
@OnlinePage
Copy link
Author

Great! I won't get into any specifics, but we don't run any Powershell script files. That block of error text however was making its way into a system call we use. We'll be applying a permanent fix for this in the next release so that this should not affect future users. Thanks for bringing this to our attention!

ya fine, thanks again! 😀😎😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants