say - macOS
Overview
say is a versatile command-line tool that converts text into synthesized speech. It leverages the built-in text-to-speech engine, offering a convenient way to audibly convey text content in various situations.
Syntax
say [options] [text to speak]
Options/Flags
- **-a : Specify the voice used for speech synthesis.
- **-r : Control the speaking rate (default: 180 words per minute).
- **-v : Adjust the volume (default: 1.0).
- **-f : Read text from the specified file.
- **-o : Output synthesized speech to a file (WAV format).
- -n: Disable any audible output (silent mode).
- -w: Wait for speech to finish before returning.
- -h: Display usage information.
Examples
- Simple usage
say "Hello, world!"
- Specify voice and rate
say -a "Whisper" -r 120 "This is spoken in a whisper at a slow pace."
- Read from file
say -f ~/text.txt
- Output to file
say -o ~/output.wav "This will output the spoken text to the specified WAV file."
- Integration with other commands
# Speak the contents of a web page using curl and say
curl -s https://example.com | say
Common Issues
- Garbled speech: Ensure that your system’s text-to-speech engine is installed and properly configured.
- No output: Check if
say
is correctly installed. Use the-n
option to verify if the command is executing without producing audible output. - Unsupported voice: The specified voice might not be available or supported by your system’s text-to-speech engine.
Integration
- Combine
say
withosascript
to create custom speech applications. - Use
say
to automate system announcements or error messages. - Integrate
say
with text editors for improved accessibility.
Related Commands
- speak: Similar to
say
, but without the ability to specify options. - afplay: Plays audio files.
- textutil: Converts text to various formats, including spoken audio.