shanecolb / sphinx-ue4

A speech recognition plugin for Unreal Engine 4. This is essentially a port of Pocketsphinx, to be used within an Unreal Engine project.
The Unlicense
150 stars 80 forks source link

Can't read microphone input in packaged game #27

Closed SubatomicPlanets closed 1 year ago

SubatomicPlanets commented 1 year ago

I created an account for this, since i really haven't found any information about it. The plugin works great in editor, but as soon as i package it, it no longer detects the microphone input. I created a "GetCurrentVolume" node that prints the volume every tick, and it is always 0. Windows always shows a small microphone icon, when an application uses it, and it does so in the editor when i click play. But in my packaged game, it doesn't show. I don't think it has to do with my windows microphone settings. In fact i tried to put in an "Audio Capture" component into my scene, and it worked... so it can't be my microphone. As i have said, I just created this account, and don't fully understand how GitHub works, so i am sorry if this is the wrong place (I actually wanted to post this in the UE5 repository, but when i clicked on Issues, it redirected me to here. It says sphinx-ue4 at the top, so sorry again if this is a very different version of the plugin) I also tried to initialize the subsystem with the "Init" node, and it returned true. I packaged it in shipped and development mode, and it doesn't work in either. I hope someone can fix this. Anyway, sorry for the spelling mistakes, I am not that great at english... Thanks.

SubatomicPlanets commented 1 year ago

Looking a bit more into the code, I found out it has to do with "ps_init". I don't know too much about coding, but it returns false. Again, it obviously returns true in the editor. It's on line 317 in "SpeechRecognitionWorker.cpp". I see that a parameter called "config" is passed. I am going to look at that next.

SubatomicPlanets commented 1 year ago

Oh... It turned out, I was a bit stupid... well, I am going to leave this here for anyone who has the same issue. I looked into the code, and saw these two lines:

modelPath = contentPath_str + "model/" + langStr + "/" + langStr; dictionaryPath = contentPath_str + "model/" + langStr + "/" + langStr + ".dict";

The variables "modelPath" and "dictionarryPath" were then fed into the "config", and that into the "ps_init". to fix it, i then copied the "model" folder, which was under my content folder in my project, to the content folder of the packaged game. and it worked! Great plugin btw!

TL;DR Copy the "model" folder from the project content to the packaged game content.