"said $v_xbmc_osd" will return true if the voice command was called in this loop.  In addition, I believe $state will be set to the alternative value of the voice command.   So if the voice command was defined as "Test XBMC Notify [on, off]"  And you called the voice command "Test XBMC Notify on" I believe $state would be set to on.  

You don't appear to currently use $state in your subroutine.  In addition, I don't see any local declaration of $state such as "my $state"  You may be getting away with this because $state is a commonly used variable, but you might want to check on this.