As developers, we spend countless hours in the terminal — running builds, executing tests, and monitoring logs. But what if your terminal could do more than display text? What if it could speak to you, offering real-time audio feedback? Enter macOS’s say
command—a built-in text-to-speech tool that transforms terminal notifications into spoken messages.
In this post, we’ll explore how to use the say
command to streamline your workflow with audio notifications. We’ll cover practical examples, from build status updates to fun and personalized reminders, helping you make the most of this underutilized gem.
What Is the say
Command?
The say
command is macOS’s built-in text-to-speech tool, accessible directly from the terminal. With just a few keystrokes, you can turn text into speech using various voices, accents, and languages.
Why Use say
?
- Real-Time Feedback: Get audio alerts without having to keep an eye on the terminal.
- Hands-Free Notifications: Perfect for multitasking or working away from your desk.
- Fun and Personalization: Customize voices and accents to suit your preferences.
Here’s how it works:
say "Welcome to the Developers Coffee blog!"
Run this in your terminal, and your Mac will speak the message using the default system voice.
Getting Started with the say
Command
Before diving into practical use cases, let’s explore some basics:
Listing Available Voices
macOS offers a variety of voices in different languages and accents. To view the full list, use:
say -v ?
Some popular voices include:
- Rishi: Indian English accent.
- Samantha: A neutral English voice with an Indian influence.
- Alex: A default American English voice.
- Victoria: Australian English accent.
- Amira: Malaysian English accent.
Trying Out a Voice
You can specify a voice using the -v
option. For example:
say -v Rishi "Hello! This is Rishi speaking."
Practical Use Cases for Developers
Here’s how you can incorporate the say
command into your day-to-day workflows:
1. Build Status Notifications
Stop staring at the terminal waiting for builds to finish! Use say
to notify you when your build is complete—or when it fails.
Example: Success Notification
#!/bin/bash
# Run your build process
./gradlew build
# Notify the user that the build is complete
say "Build complete! All tests have passed."
Example: Failure Notification
#!/bin/bash
# Run the build process
./gradlew build
# Notify if the build fails
if [ $? -ne 0 ]; then
say "Build failed! Please check the logs."
fi
2. Test Result Notifications
Automate spoken alerts for your test results. Whether your tests pass or fail, you’ll know immediately.
Example: Unit Test Results
#!/bin/bash
# Run unit tests
npm test
# Notify if the tests pass or fail
if [ $? -eq 0 ]; then
say "All tests passed successfully."
else
say "Some tests failed. Please review the errors."
fi
3. Long-Running Processes
For tasks like Docker builds, deployments, or large data migrations, audio notifications let you step away from your desk without missing updates.
Example: Docker Build
#!/bin/bash
# Run docker build
docker build -t my-app .
# Notify after build completes
say "Docker image build completed."
4. Time Management
If you use techniques like Pomodoro to stay productive, say
can help remind you when it’s time to take a break or switch tasks.
Example: Pomodoro Timer
#!/bin/bash
# Set the timer for 25 minutes (in seconds)
sleep 1500
# Notify to take a break
say "Time's up! Take a 5-minute break."
5. Dynamic Notifications
Combine say
with system variables to create custom, context-aware messages.
Example: Dynamic Service Notification
#!/bin/bash
SERVICE_NAME="MyService"
# Notify when a service starts
say "$SERVICE_NAME is now up and running!"
6. Add a Fun Twist
Brighten your day by experimenting with different voices and accents. Why not let Rishi announce your builds or Samantha remind you to leave work?
Example: Fun Custom Messages
say -v Rishi "Great job today! Time to wrap up and go home."
say -v Amira "Don’t forget to review your tasks for tomorrow!"
Advanced Tips
- Integrate with Scripts: Add
say
to your build or deploy scripts for seamless notifications. - Use Conditionals: Tailor your notifications to different outcomes (e.g., success vs. failure).
- Explore Voice Downloads: If you don’t see a voice you like, download additional voices via
System Preferences > Accessibility > Spoken Content > System Voice
.
Conclusion
The say
command is a versatile tool that can transform the way you interact with your terminal. Whether you’re looking for practical notifications, time management aids, or just a bit of fun, say
is a simple yet effective way to enhance your developer experience.
So why not give it a try? Experiment with different voices, customize your scripts, and make your terminal talk. It’s a small change, but one that can make a big difference in your workflow.
What are your favorite ways to use the say
command? Share your ideas in the comments below!