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.09k stars 1.11k forks source link

Unity Support #691

Open nshmyrev opened 3 years ago

nshmyrev commented 3 years ago

There are projects like

https://github.com/Babilinski/vosk-stt-unity

and

https://github.com/Yeti47/Vosk4Unity

Eventually we need to have our own project for that.

AmmarSalimDa commented 3 years ago

We need more examples of using it with Unity

nshmyrev commented 2 years ago

Our demo here https://github.com/alphacep/vosk-unity-asr

HezBen commented 1 year ago

hey, when I build my project Vosk doesn't work. From my understanding I am meant to put some files in the build file, but I don't know the exact details.

HezBen commented 1 year ago

hey, when I build my project Vosk doesn't work. From my understanding I am meant to put some files in the build file, but I don't know the exact details.

Never mind, I got it. turned out all my DLLs were not set up and I just forgot they existed.

ehabtawfikelbwab commented 11 months ago

Can i use Vosk for ios ?

Fortythird commented 11 months ago

hey, when I build my project Vosk doesn't work. From my understanding I am meant to put some files in the build file, but I don't know the exact details.

Never mind, I got it. turned out all my DLLs were not set up and I just forgot they existed.

Can you please provide details how did you fix it? Seems like I have the same problem with DLLs when building project with Vosk. Thank you.

HezBen commented 11 months ago

hey, when I build my project Vosk doesn't work. From my understanding I am meant to put some files in the build file, but I don't know the exact details.

Never mind, I got it. turned out all my DLLs were not set up and I just forgot they existed.

Can you please provide details how did you fix it? Seems like I have the same problem with DLLs when building project with Vosk. Thank you.

The issues I was having was directly related to the fact that I wasn't setting them up in unity. If I remember correctly I needed to find the dlls file in unity and set which ones were used in the inspector. I can't remember how, its been a while. I am trying to look up the stuff right now

Fortythird commented 11 months ago

hey, when I build my project Vosk doesn't work. From my understanding I am meant to put some files in the build file, but I don't know the exact details.

Never mind, I got it. turned out all my DLLs were not set up and I just forgot they existed.

Can you please provide details how did you fix it? Seems like I have the same problem with DLLs when building project with Vosk. Thank you.

The issues I was having was directly related to the fact that I wasn't setting them up in unity. If I remember correctly I needed to find the dlls file in unity and set which ones were used in the inspector. I can't remember how, its been a while. I am trying to look up the stuff right now

Thank you for information, I will study the issue in this direction. Please, write here if you will find solution (so will I).

Fortythird commented 11 months ago

Well, I didn't expect find solution that fast.

Anyway, here are all details related to the issue I had. Problem: missing Vosk-related DLLs when building Unity project for Windows.

Solution:

  1. Build project.
  2. In build directory open "Your-project-name"_Data -> Plugins -> x86_64. Here you will find couple of DLLs.
  3. In zip-file of your Vosk model open Packages -> Vosk -> Runtime -> Plugins -> Windows. Drag and drop all DLLs from this directory to directory in previous step.
  4. Now your project has to work properly.

Log output, when the issue occurs: DllNotFoundException: libvosk assembly: type: member:(null) at (wrapper managed-to-native) Vosk.VoskPINVOKE.new_Model(string) at Vosk.Model..ctor (System.String model_path) [0x00000] in C:\Users\ "username" \ "Project name"\Assets\ThirdParty\Vosk\Model.cs:32 at VoskSpeechToText+d__25.MoveNext () [0x000d5] in C:\Users\ "username" \ "Project name"\Assets\Scripts\VoskSpeechToText.cs:150 at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00020] in C:\buildslave\unity\build\Runtime\Export\Scripting\Coroutines.cs:17

rehberim360 commented 6 months ago

I couldn't add speaker identify for Unity. Is there anything I don't know about this topic?

b00lliie commented 1 month ago

Hello! I want to use vosk to my school project (android application). I always get this error even though I already added the libvosk.so files (this is where I got them: https://github.com/alphacep/vosk-api/releases). this is where I placed them: BB\Assets\Plugins\Android

Also when I build it and inspect the apk I can see the libvosk.so files in there.

Error message: DllNotFoundException: libvosk assembly: type: member:(null) Vosk.Model..ctor (System.String model_path) (at Assets/Plugins/Vosk/Model.cs:32) VoskSpeechRecognizer+d__5.MoveNext () (at Assets/_app/Scripts/VoskSpeechRecognizer.cs:46) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) VoskSpeechRecognizer:Start() (at Assets/_app/Scripts/VoskSpeechRecognizer.cs:27)

Fortythird commented 1 month ago

Hello! I want to use vosk to my school project (android application). I always get this error even though I already added the libvosk.so files (this is where I got them: https://github.com/alphacep/vosk-api/releases). this is where I placed them: BB\Assets\Plugins\Android

Also when I build it and inspect the apk I can see the libvosk.so files in there.

Error message: DllNotFoundException: libvosk assembly: type: member:(null) Vosk.Model..ctor (System.String model_path) (at Assets/Plugins/Vosk/Model.cs:32) VoskSpeechRecognizer+d__5.MoveNext () (at Assets/_app/Scripts/VoskSpeechRecognizer.cs:46) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) VoskSpeechRecognizer:Start() (at Assets/_app/Scripts/VoskSpeechRecognizer.cs:27)

Sup! Seems like you have the same issue as I had year ago. When building project, Vosk dll files are losing somehow, that's why you have this log - you basically don't have necessary dlls in your build. You can try to fix this following steps that I wrote here above: 1) Build project. 2) In build directory open "Your-project-name"_Data -> Plugins -> x86_64. Here you will find couple of DLLs. 3) In zip-file of your Vosk model open Packages -> Vosk -> Runtime -> Plugins -> Windows. Drag and drop all DLLs from this directory to directory in previous step. 4) Now your project has to work properly.

Hope that would help.

b00lliie commented 1 month ago

Thanks for the reply! but does this work on Android? I checked the apk in android studio and they were there but still cant seem to work

b00lliie commented 1 month ago

erm....for some reason it works now. I didnt really followed your instructions since Im not sure if it will work in android, so I asked chatgpt about it (not my proudest moment but I was desperate, sorry).

It mentioned something about the DllImport in the VoskPINVOKE.cs, chatgpt suggests some changes and I followed it and it somehow work. I can finally finish my project lol.

https://github.com/user-attachments/assets/dc3a3946-0b27-4f01-bddb-8a03bf957c14

WindGaze commented 1 month ago

erm....for some reason it works now. I didnt really followed your instructions since Im not sure if it will work in android, so I asked chatgpt about it (not my proudest moment but I was desperate, sorry).

It mentioned something about the DllImport in the VoskPINVOKE.cs, chatgpt suggests some changes and I followed it and it somehow work. I can finally finish my project lol.

460896679_8719204688109932_5252731827707458091_n.mp4

might be out of context but do you have discord or any way i can contact you? i would like some guidance about this since my game do need this

WindGaze commented 1 month ago

DllImport in the VoskPINVOKE.cs

image

uh i tried to build but i dont see any packages in my zipped model?