How to get an internal resource path in exported binary?

Hello, fellow Godot developers.

I'm developing a Speech to Text (STT) module for Godot (2.1.3 build) using an open source speech recognition library. This library uses configuration files, which I stored inside my experimental game project.

The main problem I've encountered is getting the absolute path to the configuration files to work after exporting the game; after all, the library doesn't recognize res:// paths.

The game works inside the editor, since my module can get absolute paths with the Globals singleton. For example:


The above line converts the file path on my Ubuntu 16.04 to /home/my_user/other_stuff/stt/keywords.kws. However, this absolute path doesn't work with an exported, binary game (I've tried on own Unix system), since the configuration files are stored inside the binary itself.

The only way I've found to run the binary would be to place library-related files on the same directory, but that defeats the purpose of having them inside the project in the first place! :pensive:

I've tried looking around the FileAccess and DirAccess Godot classes for a workaround, but with no success. Is there any class/function to accomplish this? Or should I store my library-related files externally (in the user:// path, for example)?

I'd really appreciate any suggestions or comments. :smile:


Tags :


  • wombatstampedewombatstampede Posts: 41Member
    Answer ✓

    The user:// directory is THE ;) place to write your own data. So in my opinion you should write/copy the required config-files there. You could check at startup if the files already exist in user:// and copy them from files in res:// if not or just copy them every time at startup to avoid problems with changed files on updates.

    Or would this be a timing problem?

  • SamuraiSigmaSamuraiSigma Posts: 6Member

    Thanks for the reply, @wombatstampede. :smile:

    I'll try copying the config files to user:// as you've said, probably at the start of the game. It shouldn't be a timing problem, as the main issue is loading the files themselves.

    I intend to release the Speech to Text module here as soon as it's finished.

Sign In or Register to comment.