DougHamil / DragonbornSpeaksNaturally

SkyrimVR mod for dialogue and other voice control
MIT License
20 stars 21 forks source link

The Algorithm #17

Open abpZ3R0 opened 4 years ago

abpZ3R0 commented 4 years ago

I am talking about this mod in my college presentation, as i wanted to talk about the future of gaming. but to do so i must show the algorithm which i don't have. i was hoping some one could provide it ??

YihaoPeng commented 4 years ago

The mod is currently maintained by me, and you can see some of the details of the mod in my README.md. https://github.com/YihaoPeng/DragonbornSpeaksNaturally

The mod is loaded by skyrim.exe in the form of a DLL and runs against the reverse engineering results of DougHamil and SKSE (https://skse.silverlock.org/).

Technically, this is not a Skyrim mod. Because it was not created with Creation Kit, it is not the usual Skyrim MOD format (.esm/.esp). In fact, you can think of it's a cheat program for Skyrim. It works like some other cheat programs.

Speech recognition is implemented by calling an external process (dsn_service). The process interacts with the DLL that started it through its stdin/stdout. dsn_service uses the .NET framework to use Microsoft's built-in speech recognition service in Windows.

YihaoPeng commented 4 years ago

Therefore, the "algorithm" of the program involves the following parts:

  1. Get the dialogue lines for Skyrim: Find the address of the function involved in the dialogue line inside Skyrim by reverse engineering and then hook it.
  2. Speech recognition: Pass the dialogue lines to the Windows speech recognition service.
  3. Get recognition results from the Microsoft Speech Recognition Service. Then use another reverse engineering hook to select a dialogue in Skyrim.
abpZ3R0 commented 4 years ago

What complexities am i looking at in terms of trying to write a pseudocode for DSN , provided i've never written a pseudocode in my life ...

SwimmingTiger commented 4 years ago

In fact, the most important algorithm in DSN: speech recognition is implemented by Microsoft, we just simply use the services it provides.

The rest is just engineering implementation, which is difficult because it involves reverse engineering and dynamic injection, which is equivalent to modifying a running car. But these complexities are all software engineering, not logical or algorithmic. The logical part of DSN itself is very simple, and there is nothing to call an "algorithm".

Dialogue process only:

LOOP BEGIN
    * Wait for the in-game dialogue.
    * Extract the dialogue lines from the game.
    * Send these dialogue lines to Microsoft's speech recognition engine.
    * Wait for the result from the speech recognition engine.
    * Select the corresponding dialogue in the game.
LOOP END

Dialogues and custom commands:

* Send custom commands in "DragonbornSpeaksNaturally.ini" to Microsoft speech recognition engine.
* Parallel 1:
    LOOP BEGIN
        * Wait for a result from the speech recognition engine.
        * Execute the corresponding custom commands in-game.
        * Wait for the next recognition result.
    LOOP END
* Parallel 2:
    LOOP BEGIN
        * Wait for the in-game dialogue.
        * Pause custom command speech recognition.
        * Extract the dialogue lines from the game.
        * Send these dialogue lines to Microsoft's speech recognition engine.
        * Wait for a result from the speech recognition engine.
        * Select the corresponding dialogue in the game.
        * Resume custom command speech recognition.
    LOOP END

DSN also has the feature "favorites menu voice-equip". When it is enabled, a new parallel process will be inserted, which I will not provide here (you should be able to see for yourself what the process will be).