sequential sound play
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
sequential sound play
I have spent hours on this and can't get it right, so I appreciate any and all help! I am working on an iPad app that has a sentence building section. The use clicks on a button to add a word (+ a space if it isn't the first word) to field "MWField". This script is used to have the field play back each word as a sentence. It works fine in the simulator, but on the iPad the first word is not played back. Any thoughts?
on speakAll
put the number of words in card field "MWField" of this card into numWords
if numWords > 0 then
repeat with n = 1 to numWords
if there is a word n of card field "MWField" then put word n of card field "MWField" & ".mp3" into var1
play (specialFolderPath("engine") & "/audio/" & var1)
wait until the sound is done
end repeat
end if
end speakAll
on speakAll
put the number of words in card field "MWField" of this card into numWords
if numWords > 0 then
repeat with n = 1 to numWords
if there is a word n of card field "MWField" then put word n of card field "MWField" & ".mp3" into var1
play (specialFolderPath("engine") & "/audio/" & var1)
wait until the sound is done
end repeat
end if
end speakAll
Re: sequential sound play
Hi ncmac
try this
Best regards
Jean-Marc
try this
Code: Select all
on speakAll
put the number of words in field "MWField" of this card into numWords
if numWords > 0 then
repeat with n = 1 to numWords
if there is a word n of field "MWField" then put word n of field "MWField" & ".mp3" into var0
put urlencode(var0) into var1
play (specialFolderPath("engine") & "/audio/" & var1)
wait until the sound is done
end repeat
end if
end speakAll
Jean-Marc
https://alternatic.ch
Re: sequential sound play
Thanks Jean-Marc, but it still isn't working. If "She is eating an apple" is in the field, the only words played back are "is eating and apple". I have tried repeat for and using word 1 to -1 and the result is always the same; The first word is not played back. I know the sound file is OK because it plays in any other position.
Re: sequential sound play
I think I have solved it. I have the first word getting capitalized, and the filename is case sensitive!
Re: sequential sound play
So now the question is if there is a way to check for an uppercase letter, behind the scenes so the user still see's the "Correct" sentence format. I checked the dictionary and didn't see anything for Uppercase, capitol or even the textStyle.
Re: sequential sound play
Hi ncmac,
check "toLower" in the dictionary. You could take your words and convert them to all lowercase on the fly when passing the word to the filename.
Kind regards
Bernd
check "toLower" in the dictionary. You could take your words and convert them to all lowercase on the fly when passing the word to the filename.
Kind regards
Bernd
Re: sequential sound play
Hi ncmac,
a short hint:
If nobody "stole" a word from the field after line 2 of your script, then the following IF THEN clause does not make any sense!
...
if there is a word n of card field "MWField" then put word n of card field "MWField" & ".mp3" into var1
...
Of course there is ALWAYS a word N of that field!
Best
Klaus
a short hint:
Code: Select all
on speakAll
put the number of words in card field "MWField" of this card into numWords
if numWords > 0 then
repeat with n = 1 to numWords
if there is a word n of card field "MWField" then put word n of card field "MWField" & ".mp3" into var1
play (specialFolderPath("engine") & "/audio/" & var1)
wait until the sound is done
end repeat
end if
end speakAll

...
if there is a word n of card field "MWField" then put word n of card field "MWField" & ".mp3" into var1
...
Of course there is ALWAYS a word N of that field!
Code: Select all
on speakAll
put the number of words in card field "MWField" of this card into numWords
if numWords > 0 then
repeat with n = 1 to numWords
put word n of card field "MWField" & ".mp3" into var1
play (specialFolderPath("engine") & "/audio/" & var1)
wait until the sound is done
end repeat
end if
end speakAll
Klaus
Re: sequential sound play
For the truly compulsive, the check for "numWords > 0" isn't required either. If numwords is zero, the repeat won't run at all. And the super-ultra-compulsive would remove all the extra lines and condense it to this:
Code: Select all
on speakAll
repeat with n = 1 to the number of words in card field "MWField" of this card
play (specialFolderPath("engine") & "/audio/" & word n of card field "MWField")
wait until the sound is done
end repeat
end speakAll
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: sequential sound play
I understand what you and Klaus are saying. Somehow it is reassuring to me to write in an exit to a script. So you are right on the compulsive part!