View Single Post
Old 11-05-08, 04:21 PM   #117
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by panthercules
Without really knowing much about the way SH4/SH3Speech is programmed, it seems to me that it should be possible in theory to separate the part of the program that recognizes the sounds from the part of the program that acts upon what has been recognized. Therefore, I'm just wondering if there wouldn't be some way to combine the front-end speech recognition aspects of Shoot with the back-end recognized command output capabilities of SH4/SH3Speech, and thereby come up with a really great voice command program for use with SH3 when played in German.
This would actually be pretty easy. In fact, I could show you how right now because I'm feeling saucy.

To do this only requires that you download perl2exe and can recompile source\voice.pl into dist\voice.exe.

Voice.pl has this line (250):

my $phrase = $_;

This line sets $phrase to equal whatever the python listener script returned. So you could just overwrite it with an extra line below, using something supplied on the command line:

$phrase = $ARGV[5];

Now if you look at your BAT launch files, you'll notice they use:

voice 1024x768 stock 1 right sh4

so $ARGV[5] would expect that you hardcode a phrase on the launch command, like this:

voice 1024x768 stock 1 right sh4 "Fire"

(Note that you may need to remove the quotes from $phrase. Try an additional line of $phrase =~ s/"//g; if necessary.)

Now, every time you run that line, it will start up, issue the Fire command to the game. Now you want it to exit immediately. So find this line (688):

# Must be at the end of the main loop

add this line below it:

last();

Below that you'll see another line:

print "Restarting speech engine...\n";

Put another last(); line *above* that. So this ought to cause it to exit cleanly.

That's it. You're done. Recompile your modified source\voice.pl into dist\voice.exe. Test the changes by running:

voice 1024x768 stock 1 right sh4 "Fire"

and ensuring that it launches, issues the command, and exits, and will repeatedly do so.

Now you just have to program Shoot to launch shSpeech like this:

voice 1024x768 stock 1 right sh4 "whatever phrase Shoot just recognized"

and of course have Shoot pass the appropriate command. shSpeech should dutifully process each phrase and then gracefully exit. Some additional performance improvements would be strongly recommended, like figuring out how to remove line 246:

open(PHRASEIN, "hear \"$ARGV[1]\" |") || die $!;

which is the command that launches the MS SAPI based python listener, which would add a tremendous level of overhead.

I hope this was informative. If the bleating is loud enough, I could do these changes myself and release an update that has this additional "one-off" mode.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 11-05-08 at 04:24 PM.
minsc_tdp is offline   Reply With Quote