Replacing revSpeechVoices()

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Replacing revSpeechVoices()

Post by Mag » Wed Oct 08, 2014 11:45 am

Hi All,

I recently discovered that if you include the script libraries of LiveCode in your standalone, you can not codesigning the app and so you can not distribute your app to any Mac users that have GateKeeper set ON, this is the majority of OS X users around the world. To learn more, see this topic: http://forums.livecode.com/viewtopic.php?f=19&t=21710 . I hope RunRev fix this problems as soon as possible. In the meantime I have to replace all the code that uses these components.

Does anyone know how I can replace this line of code with something that doesn't use RevSpeech?

Code: Select all

put revSpeechVoices() into voicesList
Last edited by Mag on Wed Oct 08, 2014 2:01 pm, edited 1 time in total.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Replacing revSpeechVoices()

Post by Klaus » Wed Oct 08, 2014 1:31 pm

Hi Mag,

not sure what you are after, but on OS X you can use SHELL with SAY.
This will put a list of available voices including info about them into a field, be sure to check all options for SAY in the terminal: man say
...
put shell("say -v ?") into fld 1
...

For XML you might get away with some REGEX?!


Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Wed Oct 08, 2014 1:53 pm

Thank you so much Klaus!

PS
I get this text with more info of the one I actually need, also it has a lot of spaces in it, to have a clean names list, I think I will set the itemDelimiter to space and then use the first item of each line. But... wait a minute! Some names have spaces inside them... :roll:

Code: Select all

Agnes               en_US    # Isn't it nice to have a computer that will talk to you?
Albert              en_US    #  I have a frog in my throat. No, I mean a real frog!
Alex                en_US    # Most people recognize me by my voice.
Amelie              fr_CA    # Bonjour, je m’appelle Amelie. Je suis une voix canadienne.
Bad News            en_US    # The light you see at the end of the tunnel is the headlamp of a fast approaching train.
Bahh                en_US    # Do not pull the wool over my eyes.
Bells               en_US    # Time flies when you are having fun.
Boing               en_US    # Spring has sprung, fall has fell, winter's here and it's colder than usual.
Bruce               en_US    # I sure like being inside this fancy computer
Bubbles             en_US    # Pull the plug! I'm drowning!
Cellos              en_US    # Doo da doo da dum dee dee doodly doo dum dum dum doo da doo da doo da doo da doo da doo da doo
Deranged            en_US    # I need to go on a really long vacation.
Diego               es_ES    # Hola, me llamo Diego y soy una voz española.
Fred                en_US    # I sure like being inside this fancy computer
Good News           en_US    # Congratulations you just won the sweepstakes and you don't have to pay income tax again.
Hysterical          en_US    # Please stop tickling me!
Ioana               ro_RO    # Bună, mă cheamă Ioana . Sunt o voce românească.
Junior              en_US    # My favorite food is pizza.
Kathy               en_US    # Isn't it nice to have a computer that will talk to you?
Kyoko               ja_JP    # こんにちは、私の名前はKyokoです。日本語の音声をお届けします。
Luca                it_IT    # Salve, mi chiamo Luca e sono una voce italiana.
Monica              es_ES    # Hola, me llamo Monica y soy una voz española.
Petra               de_DE    # Hallo, ich heiße Petra und ich bin eine deutsche Stimme.
Pipe Organ          en_US    # We must rejoice in this morbid voice.
Princess            en_US    # When I grow up I'm going to be a scientist.
Ralph               en_US    # The sum of the squares of the legs of a right triangle is equal to the square of the hypotenuse.
Trinoids            en_US    # We cannot communicate with these carbon units.
Vicki               en_US    # Isn't it nice to have a computer that will talk to you?
Victoria            en_US    # Isn't it nice to have a computer that will talk to you?
Whisper             en_US    # Pssssst, hey you, Yeah you, Who do ya think I'm talking to, the mouse?
Zarvox              en_US    # That looks like a peaceful planet.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Wed Oct 08, 2014 2:04 pm

REGEX? Could be a solution, thanks! Unfortunately I have zero experience with it. So I should have to learn it from scratch... :oops:

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Replacing revSpeechVoices()

Post by Klaus » Wed Oct 08, 2014 2:26 pm

Hi Mag,
Mag wrote:Some names have spaces inside them...
yes, but only ONE! 8)

This worked for me:

Code: Select all

on mouseUp
   put shell("say -v ?") into tVoices
   put extract_voices(tVoices) into fld 2
end mouseUp

function extract_voices tVoices
   ## The TRICK: Just replace 2 spaces with a TAB :-)
   replace "  " with TAB in tVoices
   split tVoices by CR and TAB
   put the keys of tVoices into tVoiceList
   sort tVoiceList
   return tVoiceList
end extract_voices
Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Wed Oct 08, 2014 2:35 pm

Wow, thank you Klaus, I could fall in love with your code ... :D

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Wed Oct 08, 2014 8:58 pm

OK, I spoke too soon, seduced and abandoned. It does not work :-(


PS
Here the output is the same of the imput

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Replacing revSpeechVoices()

Post by bn » Wed Oct 08, 2014 9:37 pm

Hi Mag,

there is a copy problem when copying from the forum to code

in the line

replace " " with TAB in tVoices

manually delete what is between the quotes and type 2 spaces into it.

or use

replace space & space with TAB in tVoices

then it works

it is a pesty bug in copying which introduces a ASCII 202 = nonbreaking space into the pasted content.
I even made myself a plugin to purge ASCII 202 from the clipboard. My main grief was that copied code would not indent right with ASCII 202.

Kind regards
Bernd

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Replacing revSpeechVoices()

Post by SparkOut » Wed Oct 08, 2014 11:00 pm

Mag wrote:REGEX? Could be a solution, thanks! Unfortunately I have zero experience with it. So I should have to learn it from scratch... :oops:
I'm sure if you ask nicely someone ***coughThierrycough*** could help with your regex queries. ;)

kleinmark
Posts: 1
Joined: Wed Oct 08, 2014 11:17 pm

Re: Replacing revSpeechVoices()

Post by kleinmark » Wed Oct 08, 2014 11:18 pm

nice sharing...

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

Re: Replacing revSpeechVoices()

Post by bn » Thu Oct 09, 2014 12:33 am

Hi Mag,

if you want to get rid of ASCII 202 = non breaking space from clipboard data as mentioned above then here is the code. I am not sure if it is a Mac-only thing, a Safari thing or what. Anyways ASCII 202 shows up in copied code from the forum for me.

Code: Select all

on mouseUp
   put the clipboardData ["html"] into thtml
   replace " " with " " in thtml
   set the clipboardData ["html"] to tHTML
end mouseUp
I have put that into a stack and have put it into my plugin folder. Or just use it from a button for a one-time thing.

Kind regards

Bernd

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Thu Oct 09, 2014 9:56 am

SparkOut wrote:
Mag wrote:REGEX? Could be a solution, thanks! Unfortunately I have zero experience with it. So I should have to learn it from scratch... :oops:
I'm sure if you ask nicely someone ***coughThierrycough*** could help with your regex queries. ;)
Hi SparkOut,

Thank you for your post :D

Thierry was really nice, he has created for me a complete solution ad hoc written in regex.

This is the revXML version:

Code: Select all

    put revXMLNodeContents(sXMLID, "english/forver8/lastversion") into lastversion
          put revXMLNodeContents(sXMLID, "english/forver8/downloadurl") into downloadurl
          put revXMLNodeContents(sXMLID, "english/forver8/titletext") into titletext
          put revXMLNodeContents(sXMLID, "english/forver8/infotext") into infotext
The REGEX version:

Code: Select all

-- p and pView are my Log handlers

  if matchText( theText, "<lastversion>(.*)</lastversion>", lastversion) then
     p  "Hey, I find for lastversion: " & lastversion
  end if
  if matchText( theText, "<(downloadurl)>(.*)</\1>", dummy,downloadurl) then
     p  "Hey, I find for downloadurl: " & downloadurl
  end if
  if matchText( theText, "<(titletext)>(.*)</\1>", dummy,titletext) then
     p  "Hey, I find for titletext: " & titletext
  end if
  if matchText( theText, "(?s)<(infotext)>(.*)</\1>", dummy,infotext) then
     p  "Hey, I find for infotext: " & infotext
  end if
  p "----------"
  pView
Thank you Thierry!

PS
This community is truly magnificent (is the correct word "magnificent"? Not sure if it mains what I really want to say :oops: :D )

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Thu Oct 09, 2014 9:58 am

bn wrote:Hi Mag,

if you want to get rid of ASCII 202 = non breaking space from clipboard data as mentioned above then here is the code. I am not sure if it is a Mac-only thing, a Safari thing or what. Anyways ASCII 202 shows up in copied code from the forum for me.

Code: Select all

on mouseUp
   put the clipboardData ["html"] into thtml
   replace "&nbsp;" with " " in thtml
   set the clipboardData ["html"] to tHTML
end mouseUp
I have put that into a stack and have put it into my plugin folder. Or just use it from a button for a one-time thing.

Kind regards

Bernd

Really useful tip and piece of code Bernd. It's the first time I heard about this non breaking space problem, nice to know. :idea:

jiml
Posts: 339
Joined: Sat Dec 09, 2006 1:27 am

Re: Replacing revSpeechVoices()

Post by jiml » Thu Oct 09, 2014 6:04 pm

Another variation on Klaus' code.

Code: Select all

on mouseUp
    put shell("say -v ?") into theVoiceList
   put getVoiceNames(theVoiceList) 
end mouseUp

function getVoiceNames theVoiceList
   split theVoiceList by cr and "_"
   put the keys of theVoiceList into theVoiceList
   sort theVoiceList
   repeat for each line cLine in theVoiceList
      delete word -1 of cline
      put word 1 to 2 of cline & cr after output
   end repeat
   delete char -1 of output
   return output
end getVoiceNames
Jim Lambert

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Replacing revSpeechVoices()

Post by Mag » Thu Oct 09, 2014 7:50 pm

Nice code Jim!

Post Reply