BCMM

Apr 28, 2024

BCMM Voice Commands Intro

Yes, BC has a voice command profile already, which is old. And yes, it's possible to hack a way to send keystrokes via "user32.dll" and an external speech API to have voice command support.

What's the big deal?

  1. The BC voice command profile is very old and probably obsolete.
  2. Having an external application does offer limited support, where you can only support actions that have keybindings.

So what then?

Enter the IPC support, which we demonstrated and wrote about here.

Here's the demo in action.

What is different?

This directly talks to the game and passes on messages. With the IPC API, it's possible to add any language and pass on the message to BC, where it would then perform an action based on the sent command. It doesn't matter which language-based API is used at all, as long as the messages are sent. That can be the MS Speech API or the Google API. We could even use a mobile app, should someone choose to do so.

A bit of technical info

How would one handle the messages in BC?

I am not sure if this will be in the initial release or an update, but the idea would be based on command pattern.

# Declare class
class MySuperCommandHandler(HandlerBase):
    def __init__(self):
        super().__init__(["Command: Red Alert"])

    def DoAction(self):
        return "Yay, I'm executing"

# Initialize
MySuperCommandHandler()

And base logic would handle the rest:

handlers = []

class HandlerBase:
    def __init__(self, commands):
        self.commands = commands
        global handlers
        handlers.append(self)

    def CanHandleCommand(self, command):
        if command in self.commands:
            return self
        return None

    def DoAction(self):
        pass

When a command comes in, it will look for handlers that match:

for h in handlers:
    handler = h.CanHandleCommand("Command: Red Alert")
    if handler:
        print(handler.DoAction())

Simple, effective, and easy to use.

Author: Mario  ·  posted at 20:55  ·   ·  BCMM  ipc  voice  commands