Hi all.
While I know so little about LCB, I tried anyway to put to use the FFI example that I found here:
about building a library that should do text to speech.
So I put together what is below.
My problem is that LCB report an error on the StringToNSString function: Identifier 'StringToNSString' not declared.
What don't I understand?
Code: Select all
library community.livecode.trevix.myspeech
metadata version is "1.0.0"
metadata author is "trevix"
metadata title is "MySpeech"
/**
summary: Use this to speak some text
pString: a text to speech
Returns: return the speech
Description: Take a string and return the speech
**/
foreign handler Objc_NSSpeechSynthesizerAlloc() returns ObjcRetainedId binds to "objc:NSSpeechSynthesizer.+alloc"
foreign handler Objc_NSSpeechSynthesizerInitWithVoice(in pSynthesizer as ObjcRetainedId, in pVoice as optional ObjcId) returns optional ObjcRetainedId binds to "objc:NSSpeechSynthesizer.-initWithVoice:"
handler CreateSpeechSynthesizer() returns ObjcObject
variable tSynthesizer as ObjcObject
put Objc_NSSpeechSynthesizerAlloc() into tSynthesizer
return Objc_NSSpeechSynthesizerInitWithVoice(tSynthesizer,nothing)
end handler
foreign handler Objc_NSSpeechSynthesizerStartSpeaking(in pSynthesizer as ObjcId, in pString as ObjcId) returns CBool binds to "objc:NSSpeechSynthesizer.-startSpeakingString:"
private variable mSynthesizer as optional ObjcObject
public handler SynthesizeSpeech(in pString as String) returns Boolean
if mSynthesizer is nothing then
put CreateSpeechSynthesizer() into mSynthesizer
end if
Objc_NSSpeechSynthesizerStartSpeaking(mSynthesizer, StringToNSString(pString))
end handler
end library