kdik / godot-speech-to-text

MIT License
27 stars 3 forks source link

game closes when initializing the plugin for a second time. #3

Closed LeviOS31 closed 1 year ago

LeviOS31 commented 1 year ago

i have two different scenes that need the text to speech plugin but when i load in the second scene (after coming from the first scene). the second i let go of the speaking button the game freezes and then seems to crash without giving any errors or warnings.

kdik commented 1 year ago

Hi, you should only have one instance of the node SpeechToText and reuse it in every scene.

As for your earlier question in the youtube video:

The easiest way to have two different speech-to-text models in the game would be to have two different speech-to-text plugins. To do so clone this repo and change the MODELDIR in src/stt.c and src/stt-linux.c to something like #define MODELDIR "addons/speechtotext2/model". Then rename the addons/speechtotext directory to addons/speechtotext2. Recompile the plugin by running make (or mingw32-make on Windows) in the src directory.

Then modify addons/speechtotext2/plugin.cfg, addons/speechtotext2/Plugin.gd, addons/speechtotext2/speechtotext.gdnlib, addons/speechtotext2/speechtotext.gdns, addons/speechtotext2/SpeechToText.gd to refer to the new plugin naming. Ie.: new_plugin_naming

Add the new plugin to your game manually (alongside the assetlib plugin): new_structure

Then in Godot enable the new plugin: enable_new_plugin

SpeechToText node would use one model and SpeechToText2 node could use another model.

Here's an example structure of a project, where pressing SPACE gives voice recognition using one model and pressing TAB gives voice recognition using another: project_overview

I hope this solves your use case! Feel free to ask any questions, though.