Jacob + Microsoft SpeechAPI trouble
- by guai
Following groovy code kills JVM on SetInterest method invocation
It uses Scriptom, the groovy DSL for Jacob
Spend whole day searching SAPI's SPFEI macro to rewrite it in groovy. Don't sure does it came out right. Or maybe other bugs %)
Help welcomed
import org.codehaus.groovy.scriptom.*
import static org.codehaus.groovy.scriptom.tlb.sapi.SpeechVoiceSpeakFlags.*
import static org.codehaus.groovy.scriptom.tlb.sapi.SpeechRunState.*
import static org.codehaus.groovy.scriptom.tlb.sapi.SpeechLib.*
import static org.codehaus.groovy.scriptom.tlb.sapi.SPEVENTENUM.*
def spfei(Integer[] args) {
res = 1<<SPEI_RESERVED1 | 1<<SPEI_RESERVED2
args.each {res |= 1<<it}
res
}
Scriptom.inApartment {
def voice = new ActiveXObject('SAPI.SpVoice')
evtsrc = voice.toInterface(ISpEventSource)
evtsrc.setInterest(spfei(SPEI_WORD_BOUNDARY), spfei(SPEI_WORD_BOUNDARY))
evtsrc.events.Callbacks = {args -> println 'jjj'}
voice.speak "Hello, world", SVSFlagsAsync
}