CastSpeech is a command-line tool that allows you to cast text-to-speech audio to Google Cast devices on your local network.
- Automatically discovers Google Cast devices on the local network
- Converts text to speech using Google's TTS service
- Caches generated audio files for future use
- Hosts the audio file on a temporary HTTP server
- Casts the audio to the discovered device
- Go 1.x or higher
- A Google Cast-compatible device on your local network
You can install CastSpeech using Go's package manager:
go install github.com/philippta/castspeech@latest
This command will download the latest version of CastSpeech and install it in your $GOPATH/bin directory. Make sure this directory is in your system's PATH to run CastSpeech from anywhere.
Run the program with the text you want to cast and optionally specify a language:
castspeech <text> [language]
Example:
castspeech "Hello, world!" en
If no language is specified, it defaults to German ("de").
The program will automatically discover a Google Cast device on your network, convert the text to speech, and start playing the audio.
- The program takes the input text and language (defaulting to German if not specified).
- It checks if an audio file for the given text and language already exists in the cache.
- If not found in the cache, it uses Google's TTS service to convert the text to speech.
- The generated audio is saved in the cache for future use.
- The audio file is hosted on a temporary HTTP server.
- It uses mDNS to discover Google Cast devices on the local network.
- Once a device is found, it uses the
gochromecastlibrary to connect to the device and start playback.
CastSpeech caches generated audio files in the ~/.castspeech directory. This reduces API calls and speeds up repeated announcements.
The idea for CastSpeech came from a desire to simplify the process of playing audio announcements on smart home devices. Here's the journey that led to its creation:
-
Initially, I tried to make my Alexa device announce something. However, the setup process was quite tedious:
- It required creating and managing AWS accounts
- Setting up AWS Lambda functions
- Navigating through complex configurations
- I never really got it working
-
This complexity seemed unnecessary for such a simple task.
-
Then, I discovered that a Google Home device (which I also had at home) could accomplish the same task much more easily:
- No need for external accounts or cloud services
- Works by simply sending an audio cast instruction on the local network
- Eliminates the need for all the Alexa and AWS account complications
-
This realization led to the creation of CastSpeech - a straightforward tool that leverages the simplicity of Google Cast devices to play audio announcements or files without any cumbersome setup.
CastSpeech aims to provide a user-friendly, efficient way to interact with your Google Cast devices for audio playback, making it easy for anyone to send audio to their smart speakers with minimal fuss.
This README was entirely generated by Claude, because it's late and I want to go to bed.
This project is open source and available under the MIT License.