Saving Text as an Audio File. The say command's saving as parameter adds another level of power, enabling text to be converted to audio format and saved as an.aiff file for later listening. This technique could be used, for example, to save email messages in audio format, as demonstrated by Listing 25-5. The good news is that old versions of Dragon for mac or Dragon dictate as it used to be called still work on new macs (I'm stuck with Mojave though, I don't want to risk the 32-bit issue). TextSpeech Pro is a professional text-to-speech software product, featuring high-quality voices. On OS X, it uses the Apple voices and all voices built by Cepstral. List of all features of TextSpeech Pro for OS X: Synthesizes speech from text and enables the high-quality voices (Deluxe version) in.
Convert Speech To Text Mac
Convert text to audible speech.
This tool uses the Speech Synthesis manager to convert input text to audible speech and either play it through the sound output device chosen in System Preferences or save it to an AIFF file.
If the input is a TTY, or if no text is specified, the typed input text will be spoken line by line, and the output file, if specified, will only contain audio for the last line of the input. Press Ctrl-C to cancel. Otherwise, text is spoken all at once.
Returns 0 if the text was spoken successfully, otherwise non-zero.
Diagnostic messages will be printed to standard error.
The default voice (and speaking rate) can be set in System Preferences | Dictation & Speech.
Some voices are not installed by default, selecting them in System Preferences will cause the voice to be downloaded.
Examples How to screen capture on mac pro.
say -f myfile.txt
or
cat myfile.txt | say
cat myfile.txt | say -o MyAudioFile.aiff
$ ./long-running-script ; say 'Your Script has finished running'
'We're nothing but the stories we tell ourselves' ~ Michael Montoure
Related macOS commands:
echo - Display message on screen.
pr - Convert text files for printing.
textutil - Manipulate text files in various formats.
macOS VoiceOver - Apple.com accessibility page.
wall - Write a message to users.
Windows PowerShell: Add-Type System.Speech
Some rights reserved
Speaking Text
Spoken text is another way to provide feedback to users during script execution; instead of reading a message visually, the user can listen to it audibly. Listing 25-1 and Listing 25-2 show how the Standard Additions scripting addition's say
command can be used to speak a phrase.
APPLESCRIPT
Listing 25-1AppleScript: Speaking textJAVASCRIPT
Listing 25-2JavaScript: Speaking textvar app = Application.currentApplication()
app.includeStandardAdditions = true
app.say('Processing is complete.')
The say
command has a number of optional parameters, some of which allow you to specify a voice and attributes such as speaking rate, pitch, and modulation. See Listing 25-3 and Listing 25-4.
APPLESCRIPT
Listing 25-3AppleScript: Speaking text with custom speech attributessay 'Just what do you think you're doing Dave?' using 'Alex' speaking rate 140 pitch 42 modulation 60
JAVASCRIPT
Listing 25-4JavaScript: Speaking text with custom speech attributesvar app = Application.currentApplication()
app.includeStandardAdditions = true
app.say('Just what do you think you're doing Dave?', {
using: 'Alex',
speakingRate: 140,
pitch: 42,
modulation: 60
})
Saving Text as an Audio File
The say
command's saving as
parameter adds another level of power, enabling text to be converted to audio format and saved as an .aiff
file for later listening. This technique could be used, for example, to save email messages in audio format, as demonstrated by Listing 25-5 and Listing 25-6.
APPLESCRIPT
Listing 25-5AppleScript: Saving text as audiotell application 'Mail'
tell message 1 of inbox
set theSubject to subject
set theBody to content
end tell
end tell
set theOutputFile to (path to desktop as string) & 'message.aiff'
set theAudio to 'Message Subject: ' & theSubject & return & 'Body: ' & theBody
say theAudio saving to theOutputFile
JAVASCRIPT How to detect malware on mac.
Listing 25-6JavaScript: Saving text as audiovar Mail = Application('Mail')
var app = Application.currentApplication()
app.includeStandardAdditions = true
message = Mail.inbox.messages[0]
subject = message.subject()
body = message.content()
outputFile = ((app.pathTo('desktop').toString()) + '/message.aiff')
audio = 'Message Subject: ' + subject + 'nBody: ' + body
app.say(audio, {savingTo: outputFile})
Speech To Text Software
Speaking Text While Displaying a Dialog
Typically, a script executes a single command at a time, waiting for a command to complete before moving onto the next. Listing 25-7 and Listing 25-8 demonstrate how to display a dialog message, while simultaneously using the NSTask
class in the Foundation framework to read the message out loud.
APPLESCRIPT
Mac Book Text To Speech Alexa
use framework 'Foundation'
use scripting additions
set theStatusText to 'Processing is complete.'
set theTask to (current application's NSTask's launchedTaskWithLaunchPath:'/usr/bin/say' arguments:{theStatusText})
try
display dialog theStatusText
theTask's terminate()
on error
try
theTask's terminate()
end try
end try
JAVASCRIPT
Listing 25-8JavaScriptObjC: Speaking text while displaying a dialogvar app = Application.currentApplication()
app.includeStandardAdditions = true
var statusText = 'Processing is complete.'
var task = $.NSTask.launchedTaskWithLaunchPathArguments('/usr/bin/say', [statusText])
try {
app.displayDialog(statusText)
task.terminate
}
catch(error){
task.terminate
}
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-06-13