shSpeech is a personal project that gives players voice command in the Silent Hunter 4 submarine sim video game by Ubisoft.
A solo labor of love, the project took nearly 2 months of intensive nonstop development to complete. An open source project, it was adapted by a community member to work with a previous version of the game – a testament to its adaptability. It was given to the public entirely free and developed a strong following, with the original discussion thread on Subsim reaching over 500 responses.
The app listens to what the user is saying through their microphone, then applies keyboard and mouse strokes to the game window for the matching command. The effect is striking – it is possible to do nearly everything the game allows with nothing but voice. Given that no such provision or mechanisms were built into the game itself to support this, and no assistance from the game developers was provided, it is quite an achievement.
Some of the spoken commands will result in an onscreen dial turning left or right by a certain number of degrees. Implementing this, especially with support for multiple resolutions, required the use of some moderately tricky trigonometry.
The code consists of around 850 lines of Perl, a small amount of Python, around 2000 painstakenly constructed lines of user-editable configuration (such as voice commands, coordinates of things in the game, etc). The Perl code interfaces directly to the Win32 API and Microsoft SAPI engines.
- Win32 module
- Win32::API module
- Math::Trig module
- Win32 API
- Microsoft SAPI
- Many sleepless nights