8000
Skip to content

philippta/castspeech

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CastSpeech

CastSpeech is a command-line tool that allows you to cast text-to-speech audio to Google Cast devices on your local network.

Features

  • 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

Prerequisites

  • Go 1.x or higher
  • A Google Cast-compatible device on your local network

Installation

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.

Usage

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.

How It Works

  1. The program takes the input text and language (defaulting to German if not specified).
  2. It checks if an audio file for the given text and language already exists in the cache.
  3. If not found in the cache, it uses Google's TTS service to convert the text to speech.
  4. The generated audio is saved in the cache for future use.
  5. The audio file is hosted on a temporary HTTP server.
  6. It uses mDNS to discover Google Cast devices on the local network.
  7. Once a device is found, it uses the gochromecast library to connect to the device and start playback.

Caching

CastSpeech caches generated audio files in the ~/.castspeech directory. This reduces API calls and speeds up repeated announcements.

Why

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:

  1. 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
  2. This complexity seemed unnecessary for such a simple task.

  3. 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
  4. 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.

Disclaimer

This README was entirely generated by Claude, because it's late and I want to go to bed.

License

This project is open source and available under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

0