<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>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" </div><div><br></div><div>Calling startSpeaking will call the speechSynthesizer:willSpeakWord:ofString callback and I get values such as these:</div><div><br></div><div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Null Foreign Pointer>, text=#<A Foreign Pointer #x4></div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Foreign Pointer #x5>, text=#<A Foreign Pointer #x2></div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Foreign Pointer #x8>, text=#<A Foreign Pointer #x3></div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Foreign Pointer #xC>, text=#<A Foreign Pointer #x4></div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Foreign Pointer #x11>, text=#<A Foreign Pointer #x4></div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Foreign Pointer #x16>, text=#<A Foreign Pointer #x5></div><div>sender=#<SYNTHESIZER <Synthesizer: 0x2901490> (#x2901490)> range=#<A Foreign Pointer #x1C>, text=#<A Foreign Pointer #x9></div><div><br></div><div>So far so good.</div><div><br></div><div>The callback method is defined as </div><div><font class="Apple-style-span" face="'lucida grande'" size="6"><span class="Apple-style-span" style="font-size: 19px;"><b><br></b></span></font></div><div></div></div><blockquote type="cite"><div><div><span class="Apple-style-span" style="font-family: 'lucida grande'; font-size: 19px; font-weight: bold; ">speechSynthesizer:willSpeakWord:ofString:</span></div><div><span class="Apple-style-span" style="font-family: 'lucida grande'; "><p class="spaceabove" style="margin-top: 13px; margin-bottom: 10px; font: normal normal normal 12px/normal 'lucida grande', geneva, helvetica, arial, sans-serif; ">Sent just before a synthesized word is spoken through the sound output device.</p><p class="spaceabovemethod" style="font: normal normal normal 11px/normal monaco, courier, monospace; margin-top: 13px; margin-bottom: 10px; ">- (void)speechSynthesizer:(NSSpeechSynthesizer *)<i style="font-family: 'lucida grande', geneva, helvetica, arial, sans-serif; font-size: 12px; font-style: italic; ">sender</i> willSpeakWord:(<a href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/c_ref/NSRange" target="_top" style="color: rgb(0, 0, 255); text-decoration: none; ">NSRange</a>)<i style="font-family: 'lucida grande', geneva, helvetica, arial, sans-serif; font-size: 12px; font-style: italic; ">wordToSpeak</i> ofString:(<a href="file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/c_ref/NSString" target="_top" style="color: rgb(0, 0, 255); text-decoration: none; ">NSString</a> *)<i style="font-family: 'lucida grande', geneva, helvetica, arial, sans-serif; font-size: 12px; font-style: italic; ">text</i></p></span></div></div></blockquote><div><br></div><div>Redefining the parameter list accordingly: ((Self synthesizer) Sender (wordToSpeak (* (:struct :<NSR>ange))) (text (* :<NSS>tring)))</div><div><br></div><div>results in Error: Unknown foreign type: :<NSS>TRING</div><div><br></div><div>I tried some permutations of :struct * ns:ns-string without success</div><div><br></div><div>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.</div><div><br></div><div><div>Error: Record type <NSR>ANGE has no field named :LOCATION.</div><div>>        Valid field names are: </div><div>>        NIL</div></div><div><br></div><div>What am I doing wrong?</div><div><br></div><div>all the best,  Alex</div><div><br></div><div><br></div><div>____________</div><div><div>(in-package :ccl)</div><div><br></div><div><br></div><div>(defclass SYNTHESIZER (ns:NS-Speech-Synthesizer)</div><div>  ()</div><div>  (:metaclass ns:+ns-object)</div><div>  (:documentation "Speech Synthesizer"))</div><div><br></div><div><br></div><div>(defmethod INITIALIZE-INSTANCE :after ((Self synthesizer) &rest Args)</div><div>  (declare (ignore Args))</div><div>  (#/setDelegate: Self Self))</div><div><br></div><div>(#/availableVoices synthesizer)</div><div>(#/defaultVoice synthesizer)</div><div><br></div><div><br></div><div>(defparameter *Synth1* (make-instance 'synthesizer))</div><div><br></div><div><br></div><div>(#/startSpeakingString: *Synth1* "What is the deal with these callbacks?")</div><div><br></div><div>(objc:defmethod (#/speechSynthesizer:willSpeakWord:ofString: :void) ((Self synthesizer) Sender wordToSpeak text)</div><div>  (format t "~%sender=~A range=~A, text=~A" Sender wordToSpeak text))</div><div><br></div><div><br></div><div>___________</div></div><br><div apple-content-edited="true"> <div><div>Prof. Alexander Repenning</div><div><br></div><div>University of Colorado</div><div>Computer Science Department</div><div>Boulder, CO 80309-430</div><div><br></div><div>vCard: <a href="http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf">http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf</a></div><br></div> </div><br></body></html>