A simple matrix bot that transcribes your voice to text message
Find a file
hibobmaster f6292b1a13
v1.1.1
Gracefully shutdown program

format the code
2023-07-21 12:58:39 +08:00
.github/workflows Release the code 2023-04-20 00:45:28 +08:00
.dockerignore Release the code 2023-04-20 00:45:28 +08:00
.env.example Release the code 2023-04-20 00:45:28 +08:00
.gitignore Release the code 2023-04-20 00:45:28 +08:00
bot.py v1.1.1 2023-07-21 12:58:39 +08:00
compose.yaml Release the code 2023-04-20 00:45:28 +08:00
config.json.example Release the code 2023-04-20 00:45:28 +08:00
Dockerfile Release the code 2023-04-20 00:45:28 +08:00
LICENSE Initial commit 2023-04-19 14:04:50 +08:00
log.py v1.1.1 2023-07-21 12:58:39 +08:00
README.md Add JetBrains sponsor link 2023-05-02 10:15:17 +08:00
requirements.txt v1.1.0 2023-07-20 16:04:49 +08:00
send_message.py v1.1.1 2023-07-21 12:58:39 +08:00

Introduction

This is a simple matrix bot that transcribes your voice to text message using faster-whisper, a reimplementation of OpenAI's Whisper model using CTranslate2.

Feature

  1. Liberate your hands: support automatically speech to text transcribtion
  2. Support E2EE Room
  3. Self host your service without privacy problem

Installation and Setup

  1. Edit config.json or .env with proper values
  2. Edit compose.yaml
  3. Launch the container

Here is a guide to make bot works on E2E encrypted room.

For explainations and complete parameter list see: https://github.com/hibobmaster/matrix-stt-bot/wiki

  1. Create config.json

Tips: set a non-exist room_id at the first time to prevent bot handling historical message which may mess your room up.

{
    "homeserver": "https://matrix.org",
    "user_id": "@xxxx:matrix.org",
    "password": "xxxxxxxxxx",
    "device_id": "GMIAZSVFF",
    "room_id": "!xxxxxxxx:xxx.xxx.xxx",
    "model_size": "base",
    "import_keys_path": "element-keys.txt",
    "import_keys_password": "xxxxxxxxxxxx"
}
  1. Create compose.yaml
services:
  app:
    image: ghcr.io/hibobmaster/matrix-stt-bot:latest
    container_name: matrix-stt-bot
    restart: always
    # build:
    #   context: .
    #   dockerfile: ./Dockerfile
    # env_file:
    #   - .env
    volumes:
      # use env file or config.json
      - ./config.json:/app/config.json
      # use touch to create an empty file stt_db, for persist database only
      - ./stt_db:/app/db
      # import_keys path
      - ./element-keys.txt:/app/element-keys.txt
      # store whisper models that program will download
      - ./models:/app/models
    networks:
      - matrix_network

networks:
  matrix_network:

Get your E2E room keys here: e2e-room-keys Notice: If you deploy matrix_chatgpt_bot along with this project, remember do not use the same database name.

  1. Launch for the first time
docker compose up

You will get notice: INFO - start import_keys process

After INFO - import_keys success, please remove import_keys configuration!!!

Wait a second, to see if stt_db has finished syncing_progress (The space occupied is about 100kb and above?)

Then Ctrl+C stop the container

  1. Edit config.json again

Remove import_keys_path and import_keys_password options

Set a correct room_id or remove it if you hope the bot to work in the rooms it is in.

Tips: if bot exits because RuntimeError: Unable to open file 'model.bin' in model, try rm -r models then relaunch the container.

  1. Finally

Launch the container

docker compose up -d

Demo

demo1 demo2

Thanks

  1. https://github.com/guillaumekln/faster-whisper
  2. https://github.com/poljar/matrix-nio
  3. https://github.com/8go/matrix-commander JetBrains Logo (Main) logo.