2

I have an idea in mind for a Terminal command I run often. I haven't found answers to these on my own, and they all have to do with voice/dictation:


Dictation in Terminal

Can I dictate to the Terminal? I've tried the standard Fn-Fn, but it only plays the sound effect that it makes when you've cancelled it. No microphone bubble appears either. Is it not possible to do this? I notice that in the Edit menu of Terminal, I find that Start Dictation is not greyed out; it's still an option.

Terminal > Edit > Start Dictation (fn fn)

I am positive that Dictation is setup correctly, it works great system-wide.

Reading output from Terminal

Can I get the output of one Terminal window and have it read to me by the system (via AppleScript)? I am essentially trying to reproduce this behavior with continuous output (I want every line that follows the first to be read):

Ctrl-click, Speech, Start Speaking

  • Typing fn fn in Terminal starts Dictation for me so it "should" work. Are you sure it's working in general the moment you want to use it in Terminal? – nohillside Dec 8 '12 at 16:56
2

say. You can download different voices in Mountain Lion (not sure about older versions) and can be looked up from System Preferences

Usage: say [-v voice] [-o out] [-f in | message]

You can use command | say to stream output of the command once its completed.

The famous Vicki voice from Portal.

say -v Vicki Do not adjust your screen. You will be assimilated. The process is quick and painless, stand by
1

You can assign a custom shortcut for toggling speech in System Preferences:

There's probably a better way to do this with VoiceOver, but this would speak lines as they are added.

set spoken to ""
repeat
    tell application "Terminal"
        set c to contents of window 1
    end tell
    repeat while c ends with linefeed
        set c to text 1 thru -2 of c
    end repeat
    set tospeak to c
    if tospeak starts with spoken then
        set tospeak to text (count spoken) thru -1 of tospeak
    end if
    say tospeak
    set spoken to c
    delay 1
end repeat
  • Thank you! May I ask (being new to AppleScript): could you explain the "set c to text 1 thru -2 of c" and "set tospeak to text (count spoken) thru -1 of tospeak"? (especially thru) One more question: if the contents of the Terminal window have text above and below that I don't want, can I grab the middle portion and have it spoken? I've looked at trim_line(), but it doesn't seem to be what I'm looking for... – Ethan Lee Dec 6 '12 at 6:47
  • also, this script just repeats the same thing, even if I haven't changed anything...? I'm using emacs in Terminal, if that helps. – Ethan Lee Dec 6 '12 at 6:50
  • @EthanLee I wasn't sure what you meant with continuous output, but the script is supposed to speak only new text in a normal shell session. text 1 thru -2 just removes the last character. – Lri Dec 6 '12 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .