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-30-07, 01:44 AM   #16
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by panthercules
I tried to figure out how to change the key for "fire" from "Enter" to "Ctrl+Enter", since I don't use "Enter" to fire torps
Pretty easy:

add this to key_codes.csv
CTRL-ENTER,0xA2+0x0D,0x00

As you'll notice from other lines near the bottom of that file, 0xA2 is obviously CTRL and ENTER is already defined up above as 0x0D. You can combine up to two keys using + in this way. Codes for SHIFT and ALT and anything else I forgot can be found here: http://delphi.about.com/od/objectpascalide/l/blvkc.htm (just preface all with 0x)

Next, in key_commands.csv, change the line:

12,Key,Fire,ENTER
to
12,Key,Fire,CTRL-ENTER

Since CTRL-ENTER matches the entry in key_codes.csv, that's it, you're done!

These are separate from voice_command.csv so that you can add a dozen voice commands for "fire" without worrying about putting in the right key. It's all documented at the bottom of the readme (though I realize I forgot to include the URL for the key codes... I've updated the readme.txt with this and also included links in a "docs" subfolder in the zip.)
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 07-30-07, 01:52 AM   #17
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

AHA! I'm 99% sure I've fixed the installer problems. There were two: First, one command was prompting an invisible question which would stick the bat to prevent you from reaching the next step. Second, since I'm running PPM which is actually a bat file from within another bat file, it's best to use the "call" prefix. So I'm quite sure these installer problems will go away for anyone else.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 07-30-07, 11:43 PM   #18
panthercules
The Old Man
 
Join Date: Apr 2005
Posts: 1,336
Downloads: 6
Uploads: 0
Default

Quote:
Originally Posted by minsc_tdp
Quote:
Originally Posted by panthercules
I tried to figure out how to change the key for "fire" from "Enter" to "Ctrl+Enter", since I don't use "Enter" to fire torps
Pretty easy:

add this to key_codes.csv
CTRL-ENTER,0xA2+0x0D,0x00
Great - thanks - I had the first part figured out, but I wasn't sure what the last column (0x00 above) should be (wasn't sure what a scan code was or how to figure out what the scan code should be).

Had to help someone do something tonight, so didn't get any sub time in tonight

Will have to try this out on patrol tomorrow - Now that I got my RFB install tweaked up I'm really looking forward to testing it out with this voice thing. Thanks again!
__________________
panthercules is offline   Reply With Quote
Old 07-31-07, 12:22 AM   #19
panthercules
The Old Man
 
Join Date: Apr 2005
Posts: 1,336
Downloads: 6
Uploads: 0
Default

Just did some more testing (just in test mode) to check the key change for firing - looks like it's going to work great.
This is going to be very cool - I really like being able to have multiple voice comands assigned to the same key/action, especially for things like diving (I've added "Clear the bridge" and "Lookouts below") and firing each tube. I know you still have to work a bit on the tube selection aspect, but I went ahead and set it up so "Fire one", Fire two", Fire three", etc. up to "Fire ten" all work, so I can now order the crew to fire the correct tube (assuming I've selected the right tube before I say it )

I hope there's a way to map a key/combo to open a specific tube door or doors - I'd love to be able to say "make ready all bow tubes", or "open outer doors on tubes 1 and 2" and have it actually work. I never really played using the keyboard much unless I had to (tried to use the mouse on everything possible) - with this though I'm going to have to rethink that, and check into all the possibilities of assigning keys to things I never would have messed with before.

Is there a list somewhere of every action that folks have figured out can be mapped to keys? That would be really handy for working with this speech thing (for example, can you map the weather report function to a key, or just to a button on the orders bar? - it would be great to be able to ask your watch officer for a weather report by voice command).
__________________

Last edited by panthercules; 07-31-07 at 12:46 AM.
panthercules is offline   Reply With Quote
Old 07-31-07, 07:32 AM   #20
Payoff
Captain
 
Join Date: Mar 2005
Location: Nash Town, USA
Posts: 525
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by panthercules
Just did some more testing (just in test mode) to check the key change for firing - looks like it's going to work great.
This is going to be very cool - I really like being able to have multiple voice comands assigned to the same key/action, especially for things like diving (I've added "Clear the bridge" and "Lookouts below") and firing each tube. I know you still have to work a bit on the tube selection aspect, but I went ahead and set it up so "Fire one", Fire two", Fire three", etc. up to "Fire ten" all work, so I can now order the crew to fire the correct tube (assuming I've selected the right tube before I say it )

I hope there's a way to map a key/combo to open a specific tube door or doors - I'd love to be able to say "make ready all bow tubes", or "open outer doors on tubes 1 and 2" and have it actually work. I never really played using the keyboard much unless I had to (tried to use the mouse on everything possible) - with this though I'm going to have to rethink that, and check into all the possibilities of assigning keys to things I never would have messed with before.

Is there a list somewhere of every action that folks have figured out can be mapped to keys? That would be really handy for working with this speech thing (for example, can you map the weather report function to a key, or just to a button on the orders bar? - it would be great to be able to ask your watch officer for a weather report by voice command).
Yes all of that is possible and more. Have a look in the Commands.cfg file. There are a ton of commands that are functional but never mapped to a key. I have'nt fully customized my SHIV file yet, but in SHIII I had nearly 3 full keyboards of commands (using shift/control), just so I could issue orders verbally using Shoot. I am just the opposite of you when it comes to the mouse. Mouse clicking kills immersion for me. I try to only use the mouse to look around. I use a number of multiple commands for one phrase also. Here are a few from SHIII:
"Lower all masts" - both scopes & snorkel are lowered.
"Prepare to dive" - all masts are lowered & tubes closed & dive ordered.
"Silent running" - silent running is ordered & gramophone turned off.
"At ease men" - secure from silent running & the gramophone switched back on.
"Emergency Surface" - blow ballast-go to flank speed-surface-blow ballast.

I even mapped timed inputs for the arrow keys to walk the Free camera from one station to the next, climbing ladders & going through hatches and so forth based on a verbal command. Below are a few snippets from Commands.cfg


[Cmd315]
Name=Select_tube_1
Ctxt=1

[Cmd316]
Name=Select_tube_2
Ctxt=1

[Cmd317]
Name=Select_tube_3
Ctxt=1

[Cmd318]
Name=Select_tube_4
Ctxt=1

[Cmd319]
Name=Select_tube_5
Ctxt=1

[Cmd320]
Name=Select_tube_6
Ctxt=1



;NAVIGATION OFFICER
[Cmd250]
Name=Navigation_officer
Ctxt=1
GoBack=Navigator_view

[Cmd251]
Name=Choose_destination_point
Ctxt=1

[Cmd252]
Name=Plot_course
Ctxt=1,11
MnID=0x3F060001

[Cmd253]
Name=Return_to_course
Ctxt=1
Key0=0x56,C,"V"
MnID=0x3F060004

[Cmd254]
Name=Search_pattern_1
Ctxt=1
MnID=0x3F240002

[Cmd255]
Name=Search_pattern_2
Ctxt=1
MnID=0x3F240003

[Cmd256]
Name=Search_pattern_3
Ctxt=1
MnID=0x3F240004

[Cmd257]
Name=Report_time_to_turn
Ctxt=1
Key0=0x4e,Cc,"Ctl+N"
MnID=0x3F250002

[Cmd258]
Name=Report_time_to_course_end
Ctxt=1
MnID=0x3F250003

[Cmd259]
Name=Report_range_to_course_end
Ctxt=1
Key0=0x42,Cc,"Ctl+B"
MnID=0x3F250004

[Cmd260]
Name=Report_depth_under_keel
Ctxt=1
Key0=0x42,C,"B"

[Cmd261]
Name=Report_weather
Ctxt=1
Key0=0x56,Cc,"Ctl+V"
MnID=0x3F250006

Like I said I'm just getting started customizing my SHIV.

__________________
"Hit Shokaku class carrier with three out of six torpedos. Recieved 105 depth charges during three hour period. Heard four terrific explosions in the direction of target, two and one half hours after attack. Believe that baby sank!" Lieutenant Commander Herman Kossler USS Cavalla
Payoff is offline   Reply With Quote
Old 07-31-07, 09:40 PM   #21
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

I'll have to add some basic pausing so that you can issue two keys or a series of keys with one command... should be very easy.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 07-31-07, 10:05 PM   #22
Payoff
Captain
 
Join Date: Mar 2005
Location: Nash Town, USA
Posts: 525
Downloads: 1
Uploads: 0
Default

Nice work minsc_tdp. Were you able to get the mouse inputs going, or is this still in progress?

Thanks
__________________
"Hit Shokaku class carrier with three out of six torpedos. Recieved 105 depth charges during three hour period. Heard four terrific explosions in the direction of target, two and one half hours after attack. Believe that baby sank!" Lieutenant Commander Herman Kossler USS Cavalla
Payoff is offline   Reply With Quote
Old 08-01-07, 12:23 AM   #23
panthercules
The Old Man
 
Join Date: Apr 2005
Posts: 1,336
Downloads: 6
Uploads: 0
Default

OK - I'm still not following one aspect - what exactly is a "scan code" (third column in the key_codes.csv file) and how do I know what it's supposed to be.

I'm trying to add a command for opening/closing the recognition manual, which is assigned to the "N" key in game. So, I went to the website linked to above, and found that the code for the "N" key is 4E. So, I started adding an entry to the bottom of the key_codes.csv file file, as "N | 0x4E | ???", but I can't figure out what belongs in that third column as the "scan code".

Making the changes to the key_commands.csv file seemed easy enough (presumably "59 | Key | Recognition Manual | N"), as did the changes in the voice_commands.csv file (presumably "59 | Recognition manual | Recognition manual"), but this "scan code" thing has me stumped - I couldn't detect any pattern in looking at the scan codes for the other entries in the key_codes.csv file, but then again I'm a total noob at hex stuff so I probably wouldn't be able to spot a pattern even if there is one.

Have I read right past this part in the previous explanations, or can you shed some light on how to determine what the entry in the scan code column should be for new commands we add?

[edit] OK - I still don't know what a scan code is, but I had to put something in there when I closed the files, so I just chose "0x00" like you suggested in the example about "CTRL-ENTER". This seemed to work in test mode - when I say "Recognition manual" it says it recognizes it and that it's outputting the letter "N", so I guess it worked - but if 0x00 always works, why are all the other scan codes something else? What is a scan code and what does it do?
__________________
panthercules is offline   Reply With Quote
Old 08-01-07, 12:19 PM   #24
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Well I thought I needed the scancodes and I entered them all in. Then I noticed I got some of them wrong due to being an idiot and using multiple info sources for the scan codes. Then I noticed that they tended to actually screw up the function call so I just zeroed it out in the code. Therefore it basically ignores whatever you put in that field (but it's best to put something like 0x00 to prevent warnings about empty variables and such.)

I still haven't got the mouse stuff started, I'm on vacation in TN all week. But I can't resist checking in here
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-01-07, 12:31 PM   #25
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
I did notice that it seemed to have a little more trouble recognizing commands in game than it had in the test mode - I suppose that's a natural consequence of having the game competing for priority or something.
panther noted the above in a PM and I think I have a suspicion of what's going on. Also y'all might have seen funky error messages from time to time that aren't repeatable, as in, they go away when you just say the command again.

I think the reason is that the python listener writes a file anytime an event is fired for the voice rec. This can happen at any moment. The perl script scans the file written by python, but to do this needs to open it, and if the python is writing to it at that exact moment, the file is locked, it throws an error and misses the command. For now I'll just hack this so that it detects this condition and retries until it's unlocked. The right solution is to have the two programs communicate with a better system than reading and writing files. Maybe the registry or a local IP port. I'm not much of a python coder but I'll figure something out.
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp is offline   Reply With Quote
Old 08-01-07, 03:26 PM   #26
Fraggulus
Swabbie
 
Join Date: Jul 2007
Posts: 7
Downloads: 0
Uploads: 0
Default

Hi, I got some troubles installing the ActivePerl. I downloaded the file and unzipped it. But executing the Installer.bat always shows this error message:

Can't locate warnings/register.pm in @INC (@INC contains: C:/Perl/Perl/lib .) at C:/Perl/Perl/lib/vars.pm line 7.
BEGIN failed--compilation aborted at C:/Perl/Perl/lib/vars.pm line 7.
Compilation failed in require at C:/Perl/Perl/lib/base.pm line 4.
BEGIN failed--compilation aborted at C:/Perl/Perl/lib/base.pm line 4.
Compilation failed in require at C:/Perl/Perl/lib/ActiveState/Prompt.pm line 7.
BEGIN failed--compilation aborted at C:/Perl/Perl/lib/ActiveState/Prompt.pm line 7.
Compilation failed in require at Installer.bat line 47.
BEGIN failed--compilation aborted at Installer.bat line 47.

What am I doing wrong? (The os is Win Vista Premium)

thx for any help!
Fraggulus is offline   Reply With Quote
Old 08-02-07, 09:26 AM   #27
moselgott
Watch
 
Join Date: Apr 2006
Posts: 23
Downloads: 0
Uploads: 0
Default

Hi all, I´ve got a little problem, too!

I followed all the instructions and everything was fine so far. All installing, adjusting the microphone, no problem at all. But then I wanted to start the programm

( Run "sh4speech.bat" to start the program.

When you run it, it will open a new window that says "Listening for voice commands from voice_commands.csv".)

the window opens only for less than a second and immediately closes again. Nothing happens furtheron (I think I should be able to give to commands in SH4 then, but I´m not)

Does anyone know what I did wrong / can do now?

Thanks a lot, moselgott!


EDIT: Ok, I made that window run entering "hear.py" instead of "sh4speech.bat". So that window appears with the sentence "listening for phrases from voice_commands.csv", and commands like "map" or "dive" appear there if I speek into the microphone. So I started SH4 parallel to that window and gave several commands, but nothing happened. I went back to desktop and the window showed up with all the commands I gave while Sh ran. What do I do wrong!?!?!?
Any ideas?
__________________
"War does not determine who´s right, only who´s left" - Bertrand Russel

Last edited by moselgott; 08-02-07 at 09:56 AM.
moselgott is offline   Reply With Quote
Old 08-03-07, 07:13 AM   #28
moselgott
Watch
 
Join Date: Apr 2006
Posts: 23
Downloads: 0
Uploads: 0
Default

Noone? I´m really desperate because I don´t manage to achieve anything...
__________________
"War does not determine who´s right, only who´s left" - Bertrand Russel
moselgott is offline   Reply With Quote
Old 08-03-07, 06:27 PM   #29
panthercules
The Old Man
 
Join Date: Apr 2005
Posts: 1,336
Downloads: 6
Uploads: 0
Default

Quote:
Originally Posted by moselgott
Noone? I´m really desperate because I don´t manage to achieve anything...
Unfortunately, I don't have much idea how this thing minsc did really works. We'll probably have to wait till he gets back from his trip, or gets another chance to get online from where he is now.

However, I did the same thing you did and I noticed that while it opens up the one window that repeats the commands you say, it doesn't open up the other window that opens up when I use the sh4speech.bat file - it's that second window that appears to output the key commands that are spawned by your spoken commands, and without those key commands getting output, you're not going to see any effect in the game of speaking the commands.

I noticed that when I first tried this I was getting the same "fleeting window" issue you describe - the window closes too fast to be able to tell what error message you're getting so it's hard to track down the problem. One thing you should try - run the sh4speech.bat file from a DOS command prompt box instead of from a shortcut in Windows - that way, since the DOS/command prompt window stays open, you should be able to read what error message you get when sh4speech.bat fails - depending on what that error message is, we might be able to figure out how to fix it (if it's the same message I was getting, as outlined in some of the posts above) or at least minsc might be able to give you a solution when he sees it.

Good luck!
__________________
panthercules is offline   Reply With Quote
Old 08-03-07, 11:16 PM   #30
minsc_tdp
XO
 
Join Date: Mar 2007
Posts: 411
Downloads: 1
Uploads: 0
Default

Quote:
Originally Posted by Fraggulus
Hi, I got some troubles installing the ActivePerl
First, I haven't tested this in Vista at all but I see no reason it shouldn't work.

Second, it looks like some basic libraries are not functioning - vars, base, prompt, those are really basic ones that should work fine with the default installation of activeperl.

third, I notice your paths are c:/Perl/Perl/lib/...etc. There should only be one /perl/ in there so it should be c:/perl/lib/...etc.

SO, I would recommend fully uninstalling Perl using Control Panel > Add Remove Programs and reinstalling, making sure that the full install path is simply c:\Perl. Hopefully that'll get you one step closer!
__________________
June 29 2016 - shSpeech v2.55 - Voice Command for Silent Hunter 4! View Thread
minsc_tdp 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 10:15 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.