alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
8.13k stars 1.12k forks source link

vosk.NewModel error in Golang #1638

Open fantastic0101 opened 1 month ago

fantastic0101 commented 1 month ago

Hello. everyone.

I hope you are doing well.

Now, I have encountered this problem in Golang programing.

I tried to execute the example code in Golang but there is an issue like this.

image

I already downloaded the "github.com/alphacep/vosk-api/go".

Please let me know about how to solve this issue.

Thank you.

nshmyrev commented 1 month ago

You probably misunderstood how imports work. You should not download github.com, better follow the example in the code.

fantastic0101 commented 1 month ago

I'm trying with example/test.go.

Also I downloaded the package using 'go get' command.

The package version is 0.3.50.

nshmyrev commented 1 month ago

On the screen shot you have some strange STT.go, not really example/test.go

theredcameron commented 2 weeks ago

@nshmyrev I'm running into the exact same issue. I'm running the test code with go v1.20.6 and I get the same undefined errors for NewModel and NewRecognizer. I've also used go get github.com/alphacep/vosk-api/go to obtain the library.

nshmyrev commented 2 weeks ago

@theredcameron did you try the instructions please?

https://github.com/alphacep/vosk-api/tree/master/go/example#readme

theredcameron commented 2 weeks ago

@nshmyrev Yes, I did follow the instructions. image

theredcameron commented 2 weeks ago

My apologies, I had not set CGO_ENABLED equal to 1. It was equal to 0. It works now.

theredcameron commented 2 weeks ago

@fantastic0101 Make sure the CGO_ENABLED environment variable is set to 1.