When using the say
command I can give it an option -o (file name)
for it to record to a file. However, that suppresses the audio output.
Is there a way to make it do both in one command?
command line
When using the say
command I can give it an option -o (file name)
for it to record to a file. However, that suppresses the audio output.
Is there a way to make it do both in one command?
Best Answer
It appears difficult or impossible with the built-in
say
command.You may be able to redirect the audio from
say
into a listening AUNetSend that in turn writes to disk and plays the audio; see Audio Hijack below.espeak and ffplay
You can use the open source
espeak
andffplay
tools to achieve this. The following command both says "Hello world" and creates a.wav
file of the recording:The command combines three tools:
espeak
converts the text into audio.tee
is used to divert a copy ofstdout
to a file.ffplay
plays the audio.espeak
can read from a file or web page using thef
flag:Another tool such as
ffmpeg
or iTunes can be used to convert thewav
file to an MP3 or AAC file.Install
To install espeak and ffplay, use HomeBrew or MacPorts. With HomeBrew set up, the install command is:
Audio Hijack
Alternatively, a good option is to use a third party tool like Audio Hijack:
This screen shot shows Audio Hijack taking output from Skype, recording to disk and playing back through the speaker.