Re: Mac python programming

  • From: Dave <davidct1209@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 2 Jan 2011 12:01:36 -0800

Ken,

I think you misunderstood me.  You can make C++ calls within objective
C methods (i.e.

- (void)foobar {
std::vector<std::string> x;
x.push_back("asdf");
MyCppClass.DoSomething();
}

I understand the argument convention's kinda funky, but it actually
serves to self document the code
i.e.
[foobar performActionWtihName:bla forObject:bbla2 withTime:10
inYear:2010 etc:blabla];

Requires retuning of our "speech" delimiters when we parse it with our ears :).

On 1/2/11, Ken Perry <whistler@xxxxxxxxxxxxx> wrote:
> No it is not the same difference since c++ and python at least have
> arguments and functions like I like I just have never liked the [object
> argument1: argument 2: argument3 ] type of function naming.
>
> Ken
>
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dave
> Sent: Sunday, January 02, 2011 1:11 PM
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: Mac python programming
>
> That's macports I assume?
>
> Also, objective C interoperates pretty well with C++ (only notable
> exception is that an objc class can't inherit from a C++ class and
> vice versa).  If you're messing about with emacspeak (and probably
> then lisp), instead of paren's, you're using brackets (same
> difference? sorta except for prefix operators in lisp).
>
> On 1/2/11, Ken Perry <whistler@xxxxxxxxxxxxx> wrote:
>> Well it doesn't have to be objective c there are direct libraries to c++
> as
>> well.  I will decide if I want to mess with those funcky function headers
> or
>> not. I used to code in objective c some in linux so maybe it won't hurt
> too
>> much to think with brackets again.  First thing is first though I want to
>> get this simple python ttsserver working so I can test it if it feels
>> sluggish then I will think about converting it to some binary language.
> Too
>> bad the speechSynthisizer class doesn't seem to have a speak by character.
>> I guess I could convert the character to a phoneme.
>>
>>
>> As for how I made it I just downloaded the may 2010 bz2 file and did make
>> config and make and it compiled as if I was on linux with no problems.
>>
>> Now I have to point out that I have ports installed which is where I get
>> emacs and all the linux tools like bison flex etc from.  It seems to be
>> working though.
>>
>> Ken
>> -----Original Message-----
>> From: programmingblind-bounce@xxxxxxxxxxxxx
>> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dave
>> Sent: Sunday, January 02, 2011 12:35 PM
>> To: programmingblind@xxxxxxxxxxxxx
>> Subject: Re: Mac python programming
>>
>> That's good news; I haven't messed about with building emacspeak (my
>> speech server had been used for another project).  Which build file
>> did you use (I think the main build target tries to build the linux
>> based speech servers as well)?
>>
>> I dug into emacspeak sources a bit and seems fairly easy to get it all
>> working.  It looks like you just need to modify dtk-speak.el to be
>> aware of the mac os server.  Looks like the lisp layer communicates
>> with the server via (process-send-string ) which sends the string to
>> the process using stdin.
>>
>> The way to go imo for efficiency is to write the server is native
>> objective c and link against appkit directly.
>>
>> On 1/2/11, Ken Perry <whistler@xxxxxxxxxxxxx> wrote:
>>>
>>>
>>> Ok I had to try it before I get back to work on Monday.  I just got
>>> emacspeak to compile with no problems. Well I say no problems but there
>> were
>>> about 8 warnings of packages I did not have installed to emacs but they
>> were
>>> either all lisp packages or they could be replace for example it said I
>>> didn't have w3.  I just installed w3m which I think works fine with
>>> emacspeak since it works fine with emacs.  If not I will go get the older
>>> w3.el sources.  Of course none of the packages it warned about really
> will
>>> break emacspeak it just will not allow me to do a couple things till I
> get
>>> them installed.  So anyway I now have emacspeak compiled but I have not
>>> installed it yet because I want to see if I can jerry rig it to take my
>>> ttsserver.  Heck I might even dump python all together and rewrite what I
>>> have done in c++ for speed but we will see because I would rather get it
>> to
>>> work first then make it faster.  At this rate though maybe I can get
>>> emacspeak talking next weekend.
>>>
>>> I also want to see if I can find a way to have emacsspeak run in console
>>> output mode or something where it will write the text it would send to a
>>> file that would  be helpful.
>>>
>>> Ken
>>>
>>> -----Original Message-----
>>> From: programmingblind-bounce@xxxxxxxxxxxxx
>>> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Dave
>>> Sent: Sunday, January 02, 2011 1:20 AM
>>> To: programmingblind@xxxxxxxxxxxxx
>>> Subject: Re: Mac python programming
>>>
>>> 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
>>>
>>>
>> __________
>> 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
>
>
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: