I will just use socket if I do it using python. The reason is that is what Emacspeak expects. It can pass using standard in or tcip so I will just create a regular socket at the correct port and be done with it. I have almost all the protocol done except music I can do two things there play direct or use ITunes I think I need to play it direct though because it will probably be ear cons or things of the like I will be playing. I am going to switch this to sockets next weekend if I have time and then see about getting emacspeak working on my current version of emacs which by the way is the up to date version. Ken -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dave Sent: Sunday, January 02, 2011 1:31 AM To: programmingblind@xxxxxxxxxxxxx Subject: Re: Mac python programming Usage is fairly straightforward. http://localhost:80/helloWorld! Kind of a hack, but like you, I just needed something quick and dirty at the time. The ideal way to do this would be to use Mac native IPC to pass data between a client such as emacspeak and the server py objc app. There are a few options to do this (including low-level mach ipc port primitives). Now, we should go about hooking up the emacspeak bits--haven't look at emacspeak source in a while, but would gladly help out if you've not gone there yet. On 1/1/11, Dave <davidct1209@xxxxxxxxx> wrote: > It's been a while lol...but looks like I went down the same road > before. Here's my take on a server before. Mac has a native > messaging loop (not sure what it is in terms of py objc context), but > in objc it's NSRunLoop. Looks like you've found it though in > apphelper. > > This server uses an http server to receive text from a client. Also, > would be interested in your luck compiling emacspeak on Snow Leopard. > > > """ begin server > """ > import string,cgi,time, urllib > from os import curdir, sep, system > from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer > from AppKit import NSObject > from AppKit import NSSpeechSynthesizer > """ WebServer > This script starts an http server and utilizes the Mac OS X speech > synthesis framework to generate speech received through the browser as > an url. > """ > class SpeechSynthesizerDelegate(NSObject): > def speechSynthesizer_didFinishSpeaking_(self, synthesizer, success): > sys.stdout.write("finished speaking") > > class MyHandler(BaseHTTPRequestHandler): > speechSynthesizer = NSSpeechSynthesizer.alloc().init() > delegate_ = SpeechSynthesizerDelegate.alloc().init(); > > def __init__(self, request, client_address, socket): > MyHandler.speechSynthesizer.setRate_(500) > MyHandler.speechSynthesizer.setDelegate_(MyHandler.delegate_) > BaseHTTPRequestHandler.__init__(self, request, client_address, socket) > > def do_GET(self): > > MyHandler.speechSynthesizer.startSpeakingString_(urllib.unquote(self.path)) > > def main(): > try: > server = HTTPServer(('', 80), MyHandler) > print 'started http server...' > server.serve_forever() > except KeyboardInterrupt: > print '^C received, shutting down server' > server.socket.close() > > if __name__ == '__main__': > main() > > > On 1/1/11, Ken Perry <whistler@xxxxxxxxxxxxx> wrote: >> Oh one more thing Dave. I was planning to replace the main function part >> with a socket loop that would take from the stdin and from a tcip socket >> like the protocol says I just wanted to make sure the simple stuff worked >> first. I didn't see a character speak method in NSSpeechSynthesizer >> either >> did you? If not this his how I would add the function to that script I >> just >> sent you to speak a character... If you add this right after the tts_say >> function this will make >> >> Ttsserver l <character> >> >> Work. >> >> >> #l c for speaking characters >> def l(text): >> voice = NSSpeechSynthesizer.defaultVoice() >> speech = NSSpeechSynthesizer.alloc().initWithVoice_(voice) >> speech.setDelegate_(SpeechDelegate.alloc().init()) >> speech.startSpeakingString_(text) >> funcs['l']=l >> >> -----Original Message----- >> From: programmingblind-bounce@xxxxxxxxxxxxx >> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dave >> Sent: Saturday, January 01, 2011 9:05 PM >> To: programmingblind@xxxxxxxxxxxxx >> Subject: Re: Mac python programming >> >> Agreed on the crappy docs concerning this. >> >> Tried my hand at a speech server using py obj and had the *exact* same >> problem. >> Of course, implementing the delegate (NSSpeechSynthesizerDelegate if >> memory serves), with all methods of the protocol yields no errors at >> runtime; it simply just doesn't work. >> Would be curious to see if anyone has an answer as well. >> >> On 1/1/11, Ken Perry <whistler@xxxxxxxxxxxxx> wrote: >>> >>> >>> Has anyone created a command line application and made use of delegates >> with >>> pyobjc under Mac? I am working on a project that uses the >>> NSSpeechSynthesizer class in coco and I can make the program talk fine >> but >>> I am not getting the didFinishSpeaking delegate message. If you know >>> what >> I >>> am talking about I can send you some simple sample code to check and see >> if >>> I am doing this correct. I have to say the pyobjc documentation and >> sample >>> programs suck. >>> >>> >>> >>> Ken >>> >>> >> __________ >> View the list's information and change your settings at >> //www.freelists.org/list/programmingblind >> >> __________ >> View the list's information and change your settings at >> //www.freelists.org/list/programmingblind >> >> > __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind