Skip to content

Instantly share code, notes, and snippets.

@MegaLoler
Created July 30, 2017 04:34
Show Gist options
  • Save MegaLoler/2794303ca38434cfacf3619f8bde7428 to your computer and use it in GitHub Desktop.
Save MegaLoler/2794303ca38434cfacf3619f8bde7428 to your computer and use it in GitHub Desktop.
An applescript that uses text-to-speech to read parallel texts to you line by line
-- Choose some line-aligned text files to read line by line
-- For exmaple, the first one in German, the second one in Dutch, and the third in English
-- The lines of the first file will be read aloud using text-to-speech
set srcFiles to {}
set fileLns to {}
repeat
set srcFile to (choose file with prompt ("L" & (length of srcFiles) + 1)) as text
copy srcFile to end of srcFiles
copy paragraphs of (read file srcFile as «class utf8») to end of fileLns
if length of srcFiles is 1 then
set db to "More"
else
set db to "Done"
end if
display dialog "More?" buttons {"Cancel", "Done", "More"} cancel button "Cancel" default button db
if button returned of the result is "Done" then exit repeat
end repeat
set i to 1
repeat with lnL1 in item 1 of fileLns
set msg to "L1: " & lnL1
set j to 2
repeat with lns in items 2 thru -1 of fileLns
set ln to item i of lns
set msg to msg & "
L" & j & ": " & ln
set j to j + 1
end repeat
repeat
say lnL1 with stopping current speech without waiting until completion
display dialog msg buttons {"Quit", "Repeat", "Next"} cancel button "Quit" default button "Next"
if button returned of the result is "Next" then exit repeat
end repeat
set i to i + 1
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment