vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

c# Error: System.AccessViolationException Message=Attempted to read or write protected memory.

Open rkmoray opened this issue 2 years ago • 9 comments

I am using you example for C# in .net 6 (I already tried core 3.1)

image

rkmoray avatar Jan 07 '22 20:01 rkmoray

Probably there was an earlier error, model should be null.

Please check the output for messages.

nshmyrev avatar Jan 07 '22 20:01 nshmyrev

Since I get the error on initialing the object and model has been initiated as well, this is the only error I get

image

rkmoray avatar Jan 07 '22 21:01 rkmoray

Handle is 0x0 which means there was an error on model initialization. Most likely path to the model is wrong in model constructor. Simply read the standard output of the program, it contains the reason.

nshmyrev avatar Jan 07 '22 21:01 nshmyrev

I have the same problem image

NNPopov avatar Jan 25 '22 14:01 NNPopov

15 I don't get why this isn't working! "VoskAPI" I don't know where the file is nor do I know where "model" file path is or where to redirect it too. Most open source I download works like it's suppose to, I don't get why this isn't working. I'm using VS2017 and VS2019, I install Vosk 3.31 or updated to 3.32 and still getting the same error

Skywalker200 avatar Feb 16 '22 06:02 Skywalker200

@Skywalker200 the message says you need to specify a path to the model folder in Model constructor. It suggests you to specify an absolute path to the model.

nshmyrev avatar Feb 16 '22 07:02 nshmyrev

thanks for reply! As I said below the pic, I don't know where "VoskAPI" is, nor do I know what the path for "model" is nor to were to redirect it too.

On Tue, 15 Feb 2022 at 23:02, Nickolay V. Shmyrev @.***> wrote:

@Skywalker200 https://github.com/Skywalker200 the message says you need to specify a path to the model folder in Model constructor. It suggests you to specify an absolute path to the model.

— Reply to this email directly, view it on GitHub https://github.com/alphacep/vosk-api/issues/824#issuecomment-1041177120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWZAHANEOI44ID3KL3OMKTU3NDYPANCNFSM5LPR5TAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

Skywalker200 avatar Feb 16 '22 16:02 Skywalker200

Found the solution, man, why didn't the writer of this program write this in the README.md file.

For everyone else that gets this problem, they fail to mention. You half to download the model from here, https://alphacephei.com/vosk/models The nuget that is provided with the download doesn't seem to work. After you downloaded "vosk-model-en-us-0.22-lgraph" or what ever version you downloaded. Unzip it, you will get this folder ""vosk-model-en-us-0.22-lgraph" when you double click on it, you see the same folder name "vosk-model-en-us-0.22-lgraph", this what you copy and past into "vosk-api-master\vosk-api-master\csharp\demo\bin\Debug" and change the name to "model", now this part is fix. Now if you go back to "vosk-api-master" folder, then search for the "test.wav" file. Once you find it, copy and past "vosk-api-master\vosk-api-master\csharp\demo\bin\Debug".

Now, all should be good, you will notice the program start and finish, the writer fail to enter Console.Read(); line after Console.WriteLine(rec.FinalResult()); and now you should be good to go.

I just don't get why they couldn't added this to the README.md, all of this could of been avoided.

Anyways, problem solved, Cheers!

Skywalker200 avatar Feb 16 '22 20:02 Skywalker200

Thanks for the answer. I just wanted to try this out and had no idea. Beside README.md it would be better, if there was an appropriate error message.

Matt-17 avatar May 14 '24 11:05 Matt-17