Giter Site home page Giter Site logo

homevisitlinebot's Introduction

raspi_intercom_control

This repository is an updated project developed in JPHACKS.

Overview

Intercom control with servo motors and speaker using Raspi via lineAPI.

Divice

API・Data

  • LINE Messaging API
  • LINE Notify API

Framework・service

  • FastAPI
  • cloudflare(or ngrok)

How to use this rep

  1. First, you need to capture the intercom sound via the microphone connected to the Raspi and FFT analyze it. FFT procedure for intercom sound

  2. Set Environment Variables

LINE_CHANNEL_SECRET_TOKEN=<Your_LINE_Channel_Secret_Token>
LINE_CHANNEL_ACCESS_TOKEN=<Your_LINE_Channel_Access_Token>
OPENAI_API_KEY=<Your_OpenAI_API_Key>
LINE_USER_ID=<Your_LINE_User_ID>
SWITCHBOT_AUTH_TOKEN=<Your_SwitchBot_Auth_Token>
LINE_NOTIFY_TOKEN=<Your_LINE_Notify_Token>
  • The Switch bot api is optional. (It remotely controls electricity.)
  1. Run main.py and notify.py
# Update system and install dependencies
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install tmux portaudio19-dev libopenblas-dev python3-pandas fswebcam -y

# Setup virtual environment
python -m venv env
source env/bin/activate
pip install -r requirements.txt

# Start sessions in tmux for concurrent script execution
# Session 1: Run notify.py
tmux new-session -d -s mySession 'source env/bin/activate; python notify.py'

# Session 2: Run main.py
tmux new-window 'source env/bin/activate; sudo pigpiod; uvicorn main:app --host 0.0.0.0 --port 8000 --reload'
  1. Publish main.py on the Internet

There are two ways to publish localhost to the Internet: using ngrok and using cloudflare.

Using ngrok: Sign in to https://ngrok.com/ and get your Authtoken.

wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
unzip ngrok-stable-linux-arm.zip
chmod +x ngrok
sudo mv ngrok /usr/local/bin/
ngrok authtoken YOUR_AUTHTOKEN
ngrok http 8000

With ngrok, you cannot specify a custom domain. Also note that the url will be changed each time you launch ngrok.

Using Cloudflare Tunnel: Get a domain name using a service such as Squarespace. This usually costs a fee. Configure the DNS servers to cloudflare for the domain that you have gained.

  1. Sets LINE bot webhook url Set the webhookurl of the LINE bot to the url you obtained. You must add /callback to the end of the url statement.

Demo application

homevisitlinebot's People

Contributors

yukiwith5267 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.