SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH4 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 07-22-07, 04:06 PM   #1
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default Voice Command development underway

I'm thinking of working on a voice recognition mod for SH4. As with many projects I consider starting, I think it would be pretty easy and have a rough idea of how to do it, but I'd first like to get thoughts from people here.

It would probably be a perl app since that's the only language I know, but I know it well and I know how to use the Win32 API with it. I'd use a similar approach as Enigma, where it would use the existing voice recognition libraries in Windows and translate them into keystrokes or other events. It might be tricky doing things like "rudder right 10 degrees" and other mouseclick only events with no equivalent key.

I'd be doing this mostly for myself but I'd like to hear if others would be interested, and whether folks here might help if I run into trouble?
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 07-28-07 at 05:21 AM.
minsc_tdp is offline   Reply With Quote
Old 07-22-07, 04:22 PM   #2
skwasjer
The Old Man
 
Join Date: Apr 2007
Location: Netherlands
Posts: 1,549
Downloads: 26
Uploads: 3
Default

There's already some tools out there, one I've been using for SH3 pretty much since I found it. It's called Shoot.

You can probably just use the same app (it's not related to SH, just a generic speech to keycommand app), but have to modify the config files that define the words/commands vs keys. I never got to it yet, but have thought about looking into this for SH4...

See here (or Google):
http://forums.ubi.com/eve/forums/a/t...7401057692/p/1
skwasjer is offline   Reply With Quote
Old 07-22-07, 06:48 PM   #3
Digital_Trucker
Silent Hunter
 
Join Date: Jul 2007
Location: The Peach State
Posts: 4,171
Downloads: 141
Uploads: 10
Default

I, too, used Shoot quite a bit when I played SH3. It is a nice little prog for the price ($0). As soon as I get the keyboard commands set up to my liking in SH4, I'll be doing a profile and commands.cfg setup for it.

If you download it, make sure and download the profile editor that I wrote for it, too. It will save you tons of time working with the xml profiles.

Both the voice command program and the editor are available at http://clans.gameclubcentral.com/shoot/
Digital_Trucker is offline   Reply With Quote
Old 07-22-07, 07:34 PM   #4
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

I get a crash trying to load a simple profile with one command in Shoot:

An unexpected error occurred. Full error message:
Object reference not set to an instance of an object:
at shoot.config.Configuration.load(String filename)
at shoot.MainForm.loadProfile(String file)
at shoot MainForm.openDialog_FilOk(Object sender, CancelEventArgs e)
at System.Windows.Forms.FileDialog.OnFileOk(CancelEve ntArgs e)
at System.Windows.Forms.FileDialog.DoFileOk(IntPtr lpOFN)

Any help with that?

In the meantime, I've been experimenting with sending mouse input and keystrokes to SH4. Both work well. Here's an example of keyboard input:

use Win32::API;
my $keybd_event = new Win32::API("user32", "keybd_event" , [qw(I I N P)], 'V') or die "keybd_event: " . Win32::FormatMessage (Win32::GetLastError ());

use constant F1 => 0x70;
use constant SC_F1 => 0x3B;
use constant X => 0x58;
use constant SC_X => 0x2D;

while (1) { # keep pressing the key so i can switch to sh4
sleep(2);
press_key(C, SC_C); # Crash dive!
}

sub press_key {

my $bVk = shift;
my $bScan = shift;
$keybd_event->Call($bVk, $bScan, KEYEVENTF_EXTENDEDKEY, 0);
sleep(1);
$dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
$keybd_event->Call($bVk, $bScan, $dwFlags, 0); # release key

}

And here is an example mouse movement:

use Win32::GuiTest qw/:ALL/;

MouseMoveAbsPix(693,692);
sleep(1);
MouseMoveAbsPix(723,693);
SendMouse("{LEFTDOWN}");
sleep(1);
SendMouse("{LEFTUP}");
sleep(1);
# Speed is now set to Full, will break with different resolutions though.


So, assuming I can get the voice recognition code to work properly, which doesn't look too hard, I have everything I need for precise SH4 control, including specific depth levels and all the keys! Exciting... now to see if I actually finish this

If someone can give me a basic Shoot profile for SH4 that does even a few keys, I'll prefer that route and I'll probably go to the trouble of finishing the profile. I've heard it has trouble with certain keys like the backtick ` but we'll have to see.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 07-22-07 at 07:55 PM.
minsc_tdp is offline   Reply With Quote
Old 07-22-07, 07:57 PM   #5
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

BTW here is the shoot profile XML that crashes when I load it:

<?xml version="1.0" encoding="utf-8"?>
<!--- - - - -This profile created with Digital_Trucker's Shoot Profile Editor- - - - - - -->
<!--- - - please address all correspondence to Digital.Trucker@Yahoo.com - - - - - -->
<shoot-config>
<command-list key-delay="0.10">
<command name="C" phrase="dive" />
</command-list>
<push-to-talk initial-state="" />
</shoot-config>

I tried dropping in the new shoot.exe.config file at http://www.gameclubcentral.com/modul...ewtopic&t=3945 but it didn't work. When I load the EXE nothing happens, no process loads or anything. It looks like it only adds a new section, something about SupportedRuntime with a version number. Maybe they haven't updated this properly for .NET 3.0 yet?

UPDATE: I think it's because I only have .NET 2.0 installed. And you can have more than one at the same time, so I'm installing 1.1 and 3.0 (for thoroughness).
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 07-22-07 at 08:08 PM.
minsc_tdp is offline   Reply With Quote
Old 07-22-07, 08:19 PM   #6
Digital_Trucker
Silent Hunter
 
Join Date: Jul 2007
Location: The Peach State
Posts: 4,171
Downloads: 141
Uploads: 10
Default

Check out the sticky at the top of the game club central shoot support forum at http://www.gameclubcentral.com/modul...viewforum&f=39

It explains what you have to do to get Shoot to work with any .NET after 1.1. The author of the software hasn't updated it, but you can make it work as long as you have .NET 1.1 installed alongside 2.0 or 3.0. I hear he is in the process of rewriting it, but haven't seen it yet.

You can download my SH3 profile for Shoot at http://www.gameclubcentral.com/modul...r_III_EXPANDED

The only problem with that is that they changed the format of the commands.cfg file with SH4 and the key bindings file supplied with the Shoot profile will not work with SH4. You'll have to do the same thing I've been putting off (hoping that we'd get a nice tool like Setkeys for SH4) and that is map all the keys manually.

I may break down and go ahead and do it and get it over with. I think that's the last thing I need to do before I can start playing the game for real :rotfl: .

However, if you are going to write something that will handle the things that Shoot can't do, then it's all a moot point.
Digital_Trucker is offline   Reply With Quote
Old 07-28-07, 05:31 PM   #7
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Version 1.0 is done and out the door!

http://www.subsim.com/radioroom/show...880#post606880

No mouse stuff yet.
Full support of all default key commands.
Several good additional voice command entered for certain commands (like "quiet" and "silence" in addition to "silent running" for silent running mode)
Excellent voice recognition! I am ecstatic about how well it is working. Be sure to read the guide on tuning your mic and configuring and training speech!

This thread is officially closed, please move all discussion to the other. Thanks everyone!

Mods, please lock this thread?
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 07-28-07 at 05:56 PM.
minsc_tdp is offline   Reply With Quote
Old 07-28-07, 06:36 PM   #8
skwasjer
The Old Man
 
Join Date: Apr 2007
Location: Netherlands
Posts: 1,549
Downloads: 26
Uploads: 3
Default

I have not tested your release, too busy with my own project :p

I did think of one thing: with mouse related commands, try to keep in mind the different resolutions people will be using. You could use screen offsets instead of absolute values in the config, so that users would only need to specify their resolution, and the tool calculates where the actual click must take place. Like for rudder: bottom - n pixels, right - n pixels. Otherwise, it would be a serious pain to recreate configs for all resolutions (don't forget widescreen!).
skwasjer is offline   Reply With Quote
Old 07-28-07, 11:06 PM   #9
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by skwasjer
I have not tested your release, too busy with my own project :p

I did think of one thing: with mouse related commands, try to keep in mind the different resolutions people will be using. You could use screen offsets instead of absolute values in the config, so that users would only need to specify their resolution, and the tool calculates where the actual click must take place. Like for rudder: bottom - n pixels, right - n pixels. Otherwise, it would be a serious pain to recreate configs for all resolutions (don't forget widescreen!).
Yeah I'm keenly aware of that, it's not as simple as an offset since the controls are completely moved for the different resolutions. The x/y coordinates of everything would need to be done for all resolutions no matter what.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.