Jacob + Microsoft SpeechAPI trouble

Posted by guai on Stack Overflow See other posts from Stack Overflow or by guai
Published on 2011-01-02T23:51:33Z Indexed on 2011/01/02 23:53 UTC
Read the original article Hit count: 563

Filed under:
|
|
|
|

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
}

© Stack Overflow or respective owner

Related posts about groovy

Related posts about text-to-speech