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 08-07-07, 01:23 PM   #46
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by Fraggulus
I didn't find any SDK for Vista. Maybe because of the already built-in speech recognition??
Probably. Go to command prompt, cd \sh4speech and run perl go.pl and python hear.py and post the output of those two commands seperately. I still haven't had a chance to try on Vista at home. Oh also just try installing the regular XP SAPI 5.1 SDK into Vista. A lot of XP stuff should work fine in Vista and I don't see why this is different. Ultimately it would probably be nice to use the newer 6.0 speech recognition engine that Vista has, but I tell ya the 5.1 is good enough for this tiny set of commands.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 08-07-07 at 01:48 PM.
minsc_tdp is offline   Reply With Quote
Old 08-07-07, 01:26 PM   #47
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by moselgott
I think a chain system is a valuable addition to that. A good use for it would be "open all tubes" (w&q&w&q&w....), but I think it is not usable for selecting singular tubes, because in order to get from tube 6 to tube 1 you would have to say "select tube 5", so that 5 tubes are cycled to reach tube 1. Did I get that right? If yes, I wouldn´t like, but it is likable for other commands though.

Nontheless I couldn´t solve my problem. Why is tube 2 selected when pushing Ctrl+F1? And why is there no possibility to select tubes 1,8,9,10?
First, note that there is already an "open all tubes" command that you could set up if I haven't already added it. And since that's a keystroke that would probably be ideal. The chaining thing will not solve singular tube selection on its own. Having thought about this a lot, here's the only way I think we can handle tubes:

1. First you speak an initialization command such as "recognize 6 tube configuration" or simply "i have 6 tubes". This would set a variable that would help it keep track of how many cycles are needed to reach a given tube.

2. In the config files I would add something like "open tube 1" through "open tube 10" and the "key sequence" would not be a normal one, but rather something special that would instruct the script to first A.) check the current tube configuration, B.) cycle n tubes, open, and stay there (since you usually press Fire right after.) So, if you're on a 10 tube boat and open/fire tube 7, then say open tube 2, it would know to cycle 5 times, since it knows you're on 7, since it put you there initially with an earlier command.

3. It would also need to start with the assumption that all tubes are closed and that it will always control opening and closing of tubes. This way, if you say "open" and it's already open, it won't toggle it and cause it to close.

This not only solves the problem that there doesn't seem to be a way to map a key to these tubes, but it will probably work extremely well, assuming the game reacts to rapid-fire tube cycling (if not, we can always add a delay since this whole command sequence is somewhat special.) The only drawback is that it would require that you never use the mouse or keys to select tubes, or if you do, you'd need to remember to select tube 1 before using the voice command.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 08-07-07 at 06:36 PM.
minsc_tdp is offline   Reply With Quote
Old 08-07-07, 11:31 PM   #48
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Just posted a quick 1.2 version with bugfixes for the multi-key sequences and debug output since it was horribly broken. See what happens when you don't bother to test?

See first post at top of thread for download link/readme
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-08-07, 12:55 AM   #49
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Just posted 1.3 with tube door management!

Amazingly the entire codebase for both scripts is only 391 lines, and that includes a lot of whitespace. God I love Perl.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-08-07, 04:58 AM   #50
Andi78
Bilge Rat
 
Join Date: Aug 2007
Posts: 1
Downloads: 0
Uploads: 0
Default

Thank you for this unbelievebale Mod. Is there a chance for a german version?
Andi78 is offline   Reply With Quote
Old 08-08-07, 11:33 AM   #51
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by Andi78
Thank you for this unbelievebale Mod. Is there a chance for a german version?
I don't speak German very well (I took it in high school for 4 years and was actually pretty good, but that was over 10 years ago and I've forgotten almost all of it.)

I see no reason others couldn't localize the CSV files and post them. If someone did I'd be happy to include it in the ZIP. Some minor changes might be required to the code but I doubt it. You choose the language of the speech recognizer in Control Panel > Speech and I don't think the code cares what language you're in.

You might even be able to get away with using phonetic equivalents of german words in the CSV file. For "command room" as "Befehl Raum" you could try "befell raum" or "befell roam" for example.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 08-08-07 at 01:12 PM.
minsc_tdp is offline   Reply With Quote
Old 08-08-07, 02:11 PM   #52
moselgott
Watch
 
Join Date: Apr 2006
Posts: 23
Downloads: 0
Uploads: 0
Default

Wouldn´t this require a german sdk version?
__________________
"War does not determine who´s right, only who´s left" - Bertrand Russel
moselgott is offline   Reply With Quote
Old 08-08-07, 03:42 PM   #53
Fraggulus
Swabbie
 
Join Date: Jul 2007
Posts: 7
Downloads: 0
Uploads: 0
Default

Quote:
Originally Posted by minsc_tdp
Probably. Go to command prompt, cd \sh4speech and run perl go.pl and python hear.py and post the output of those two commands seperately. [...]
Hi minsc_tdp,

the output of the commands is as follows..

1st) perl go.pl:
Code:
sh4speech 1.3 by Minsc (Erik Knepfler)
Press CTRL-C when finished.

Initializing...
Cleanup (deleting phrase.tmp)
Caching key_codes.csv
Caching voice_commands.csv
Caching key_commands.csv
Waiting for a phrase to appear in phrase.tmp...
2nd) python hear.py:
Code:
Traceback (most recent call last):
  File "hear.py", line 113, in <module>
    speechReco = SpeechRecognition(wordsToAdd)
  File "hear.py", line 35, in __init__
    self.context = self.listener.CreateRecoContext()
  File "C:\Users\User\AppData\Local\Temp\gen_py\2.5\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x3.py", line 2638, in CreateRecoContext
    ret = self._oleobj_.InvokeTypes(10, LCID, 1, (9, 0), (),) pywintypes.com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (0, None, None, None, 0, -2147467259), None)
Fraggulus is offline   Reply With Quote
Old 08-08-07, 04:00 PM   #54
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by moselgott
Wouldn´t this require a german sdk version?
Possibly, but I don't know if the full SDK is even really needed. It really just hooks into the speech recognizer which is built into windows. Control Panel > Speech - if that's set up and working, I think the hear.py code should work. The speech control panel has settings to pick a recognizer in a specific language. I hope I don't have to install a german language version of Windows just to figure this out. Maybe after I fix the Vista issues that will clear some of this up.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-08-07, 06:40 PM   #55
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Just added a prioritized TODO list to the top-level post.

UPDATE: I just spent some time in Vista trying to get this to work. Epic failure. hear.py looks like it needs some serious work for Vista. I made a little progress with some guesswork but I think the fundamental approach of using COM dispatching to hook into SAPI is just no good. The Vista stuff claims to be backward compatible but I'm not seeing it. If someone wants to tackle this, just google some of the unique comments in hear.py to find the original work and maybe harass the author. Or, find a simple working python example of a listener that repeats your spoken commands (no matter how badly, it just needs to be hooked into the CSVs) and I'll do the rest. Sorry! Really, nobody should be playing SH4 in Vista anyway... it kills your FPS you know.)
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread

Last edited by minsc_tdp; 08-09-07 at 01:10 AM.
minsc_tdp is offline   Reply With Quote
Old 08-09-07, 02:12 PM   #56
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default minor tube bug

Noticed a minor tube bug very late last night, I was too tired to fix it. I'm going to update the zip with this, but here it is for now in case this is bothering anyone:

Problem: If you're on tube 3 (which sh4speech knows) and you load a game or otherwise reset things, you'll be on tube 1. When you use the tube reset command "set all tubes closed" it still thinks you're on tube 3 and when you use any tube command it will use the wrong tube every time from that point forward.

Solution:
Set the internal "current_tube" variable to 1 when "set all tubes closed" command is issued.

Code patch (insert as line 160. should be inside the ALLCLOSE if block)
$VARS{"current_tube"} = 1;

So that general area should look like:

Code:
 
if ($data eq "ALLCLOSE") {
   for my $tube (1..$tubes) {
      print "\t\tSetting tube $tube status to CLOSE\n";
      $VARS{"tube".$tube."status"} = "CLOSE";
   }
$VARS{"current_tube"} = 1; # If tubes are reset/allclosed, game was probably saveloaded or restarted and we're back on tube 1
} else {
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-10-07, 02:00 PM   #57
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default hey guys!

I've found a simple solution that not only increases the recognition speed by about 10x, but also eliminates the extra window. I'll have that in tonight, along with the tube fix above. The 100x improvement is just the time between when the Python script catches it to when the Perl script notices it, which is already only about 1/10th of a second, but now it will be 1/100th of a second. It also fixes the rare chomp() error that causes the Perl script to not catch the command from the Python script. I can't believe I didn't do this to begin with, it solves so much.

Keep in mind the biggest factor in the speed of recognition is the settings in Control Panel > Speech. There's a slider that says fast/loose or slow/accurate. Try to make it fast but test test test...
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-10-07, 09:13 PM   #58
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default 1.35 posted

v1.35 posted.
http://knepfler.com/sh4speech1.35.zip

1.35 Minor enhancement and bugfixes

Bugfixes:
"set all tubes closed" now sets the current_tube variable to 1 since loading a savegame, docking, or any other condition that causes you to use this command probably means it's not still on tube 3 or whatever your last tube was.

Enhancements:
Added "reset tubes" and "reset all tubes" voice command alias for "set all tubes closed" since that makes more sense.
Eliminated python popup window by using command line pipe redirection instead
Increased recognition speed from a polling rate of 10x per second to instantaneous with above trick
Both programs must now terminate together which is nice, since sometimes various restarts would result in two hear.py's running
Removed some extraneous junk files from the package, including wxPython which is actually not needed. Drastically shrinks the ZIP size too

Compatibility:
Two voice command aliases added for id #95 (just some tube reset commands)
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-11-07, 03:22 AM   #59
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

v1.38 posted, more minor fixes.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-11-07, 03:48 PM   #60
GhengasCon
Swabbie
 
Join Date: Jul 2007
Posts: 11
Downloads: 238
Uploads: 0
Default

Hello!,
I really want to try this out but am having major ( or possibly minor) install problems. My problem seems to be the same that panthercules had in his 7/31/07 post. The program doesn't recognize or install GUITest . Here is what it looks like when i try to install.....

Starting wxPython install
The system cannot find the path specified.
Installing additional perl modules
No missing packages to install
No missing packages to install
ppm install failed: 404 File `\sh4speech\libraries\Win32-GuiTest\Win32-GuiTest.p
pd' does not exist
File not found - SAPI5.pm
A subdirectory or file \perl\site\lib\win32 already exists.
A subdirectory or file \perl\site\lib\win32\guitest already exists.
The system cannot find the path specified.
The system cannot find the path specified.
Everything should be done now.
Press any key to continue . . .


I tried to do all the fixes that you suggested to him but i continue to have the same problem. I am not a computer whiz ( wish i was) but i enjoy and appreciate all the work modders like yourself do...I hope yiou can help because i said all along that voice recognition is all the SH4 needed to be complete...would love to try this out...Thanks!!!
GhengasCon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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 09:28 AM.


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