[Openmcl-devel] delegate problems

Alexander Repenning ralex at cs.colorado.edu
Thu Dec 18 10:16:52 PST 2008


The code below using the mac speech synthesizer works to the point  
where the speech is produced and the delegate methods are run. Usually  
this would be the hard part. Instead I have problems with getting the  
right values from these "callbacks"

Calling startSpeaking will call the  
speechSynthesizer:willSpeakWord:ofString callback and I get values  
such as these:

sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Null Foreign Pointer>, text=#<A Foreign Pointer #x4>
sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Foreign Pointer #x5>, text=#<A Foreign Pointer #x2>
sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Foreign Pointer #x8>, text=#<A Foreign Pointer #x3>
sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Foreign Pointer #xC>, text=#<A Foreign Pointer #x4>
sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Foreign Pointer #x11>, text=#<A Foreign Pointer #x4>
sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Foreign Pointer #x16>, text=#<A Foreign Pointer #x5>
sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A  
Foreign Pointer #x1C>, text=#<A Foreign Pointer #x9>

So far so good.

The callback method is defined as

> speechSynthesizer:willSpeakWord:ofString:
> Sent just before a synthesized word is spoken through the sound  
> output device.
>
> - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender  
> willSpeakWord:(NSRange)wordToSpeak ofString:(NSString *)text
>

Redefining the parameter list accordingly: ((Self synthesizer) Sender  
(wordToSpeak (* (:struct :<NSR>ange))) (text (* :<NSS>tring)))

results in Error: Unknown foreign type: :<NSS>TRING

I tried some permutations of :struct * ns:ns-string without success

Second problem is to try to access the struct values using (pref  
wordToSpeak :<NSR>ange.length) claiming that the <NSR>ange struct has  
no field called length and further claiming that <NSR>ange has only a  
field called nil.

Error: Record type <NSR>ANGE has no field named :LOCATION.
 >        Valid field names are:
 >        NIL

What am I doing wrong?

all the best,  Alex


____________
(in-package :ccl)


(defclass SYNTHESIZER (ns:NS-Speech-Synthesizer)
   ()
   (:metaclass ns:+ns-object)
   (:documentation "Speech Synthesizer"))


(defmethod INITIALIZE-INSTANCE :after ((Self synthesizer) &rest Args)
   (declare (ignore Args))
   (#/setDelegate: Self Self))

(#/availableVoices synthesizer)
(#/defaultVoice synthesizer)


(defparameter *Synth1* (make-instance 'synthesizer))


(#/startSpeakingString: *Synth1* "What is the deal with these  
callbacks?")

(objc:defmethod (#/speechSynthesizer:willSpeakWord:ofString: :void)  
((Self synthesizer) Sender wordToSpeak text)
   (format t "~%sender=~A range=~A, text=~A" Sender wordToSpeak text))


___________

Prof. Alexander Repenning

University of Colorado
Computer Science Department
Boulder, CO 80309-430

vCard: http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20081218/0081bf44/attachment.htm>


More information about the Openmcl-devel mailing list