Skip to content

A rest api for OctoPi Webhooks in docker. The API calls trigger audio tracks describing the event. New messages are run through DeepGram to convert from text to speech on first use. The Deepgram response is stored locally for cost saving.

Notifications You must be signed in to change notification settings

JeBear76/printer-hooks-docker

Repository files navigation

Printer Hooks Docker

This project sets up a Docker environment for managing printer hooks. It allows you to easily deploy and manage printer hooks using Docker containers.

This project requires Docker Desktop running on WSL2.
A WSL2 Ubuntu 24.04 VM. I use the Microsoft Store one.
OctoPrint and the OctoPrint-Webhooks plugin.
I use DeepGram to generate the audio. If you don't provide the image with a DEEPGRAM_API_KEY, it'll use default wav files. Otherwise, it'll build a new text based on the DEVICE IDENTIFIER and topic is receives, send that to DeepGram and save the file in the audio folder. This only happens once.

Table of Contents

Installing PulseAudio on Windows

follow these instructions

Installation

Using DockerHub

  1. Pull the image.
docker push jerepondumie/printer-webhooks:latest
  1. Create an empty audio folder somewhere.

  2. Run the container.

# Windows WSL2 (Example)
docker run \
    -d \
    -v ./audio:/usr/src/app/audio \
    --mount type=bind,source=/mnt/wslg/PulseServer,target=/mnt/wslg/PulseServer \
    -e HOST_NAME=$(hostname) \
    -e PULSE_SERVER=unix:/mnt/wslg/PulseServer \
    -e DEEPGRAM_API_KEY=$DEEPGRAM_API_KEY \
    -p 80:5000 \
    jerepondumie/printer-webhooks
# Ubuntu 24.04 (Example)
docker run \
    -d \
    --restart=always \
    -v ./audio:/usr/src/app/audio \
    --mount type=bind,source=/run/user/1000/pulse/native,target=/run/user/1000/pulse/native \
    -e HOST_NAME=$(hostname) \
    -e PULSE_SERVER=unix:/run/user/1000/pulse/native \
    -e DEEPGRAM_API_KEY=<YOUR_DEEPGRAM_KEY> \
    -p 80:5000 \
    jerepondumie/printer-webhooks

Manual

  1. Clone the repository:

    git clone https://github.com/jebear76/printer-hooks-docker.git
    cd printer-hooks-docker
  2. Create an empty audio folder in the solution.

  3. Setup your DeepGram API Key (optional)

        echo DEEPGRAM_API_KEY=<YOUR_DEEPGRAM_KEY> > .env
        source .env
    
  4. Run the docker run script:

    . ./runDocker.sh

By default, the runDocker.sh script exposes the api on port 80 of the host. You can go to http://localhost

Usage

Configure your Octopi Webhooks.
For this, the writer of the OctoPrint-Webhooks wrote a README.

You can add a specific voice for the printer in the DATA json under Advanced. For example.

{
  "deviceIdentifier":"@deviceIdentifier",
  "apiSecret":"@apiSecret",
  "topic":"@topic",
  "message":"@message",
  "extra":"@extra",
  "voice":"aura-asteria-en"
}

A full list of the deepGram voice models is available here

DeepGram Config

You can change the default voice for the DeepGram API in the config.json.
I created the class for another project. The other 2 config settings are useless in this one.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A rest api for OctoPi Webhooks in docker. The API calls trigger audio tracks describing the event. New messages are run through DeepGram to convert from text to speech on first use. The Deepgram response is stored locally for cost saving.

Resources

Stars

Watchers

Forks