Code Monkey home page Code Monkey logo

personal-backend's Introduction

Personal Mycroft Backend

Personal mycroft backend alternative to mycroft.home, written in flask

Official mycroft backend has been open sourced, read the blog post

This repo is an alternative to the backend meant for personal usage, eventually this will become an out of the box solution to run completely offline. It is the backend only, the plan is to make it compatible with the official selene ui.

If you need to manage multiple user accounts this project is not for you!

๐Ÿšง UNDER CONSTRUCTION

WARNING: This project is incomplete and not actively maintained.

Mycroft Backend API docs can be found here

The original author of this project is continuing work at https://github.com/OpenVoiceOS/OVOS-local-backend

Install

from source

git clone https://github.com/MycroftAI/personal-backend
cd personal-backend
pip install .

from pip

pip install git+https://github.com/MycroftAI/personal-backend.git

configure backend by editing/creating ~/.mycroft/personal_backend/personal_backend.conf

{
"backend_port": 6712,
"ssl": true,
"ssl_key": "/home/user/.mycroft/personal_backend/certs/MycroftPersonalServer.key",
"ssl_cert": "/home/user/.mycroft/personal_backend/certs/MycroftPersonalServer.crt",
"mail_port": 465,
"mail_server": "smtp.googlemail.com",
"mail_user": "[email protected]",
"mail_password": "xxx"
}

change url in "server" section in your default mycroft config

 // Address of the REMOTE server
  // Override: none
  "server": {
    "url": "http://0.0.0.0:6712",
    "version": "v1",
    "update": true,
    "metrics": true
  },

if you want to perform TTS in the backend side change the mimic2 url

"tts": {
    "module": "mimic2",
    "mimic2": {
      "lang": "en-us",
      // this will allow you to use any number of tts on personal backend
      // currently supported: google, mimic2
      // "url": "http://0.0.0.0:6712/synthesize/google/female/en-us?text=",
      "url": "http://0.0.0.0:6712/synthesize/mimic2/kusal/en-us?text=",
      "preloaded_cache": "/opt/mycroft/preloaded_cache/google"
    },

usage

start backend

from personal_mycroft_backend.backend import start_backend

start_backend()

more examples here

Features / Routes

  • get location

  • geoip location default

  • get config

  • get device settings

  • patch device settings

  • pairing process

  • send mail

  • multiple STT engines supported (google, wit, ibm, kaldi, bing, houndify, govivace, deepspeech)

  • sql database

  • remote TTS, mocking mimic2 api:

    • google TTS
    • Mimic2 Proxy

Credits

Thanks goes out to JarbasAI for creating this initial implementation. You can find the archived original repo here.

personal-backend's People

Contributors

el-tocino avatar hckr avatar jarbasal avatar krisgesling avatar matthewscholefield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

personal-backend's Issues

Client cannot connect to the server

Hi I have changed all settings and disabled SSL (for client - conf http instead of https, and for backend server conf ssl from true to false).
Client cannot connect to the server. Server log:
127.0.0.1 - - [16/Jan/2019 21:04:14] "GET /v0.1/device/ HTTP/1.1" 404 -
127.0.0.1 - - [16/Jan/2019 21:04:19] "GET /v0.1/device//subscription HTTP/1.1" 404 -
127.0.0.1 - - [16/Jan/2019 21:04:20] "GET /v0.1/device/ HTTP/1.1" 404 -
...
127.0.0.1 - - [16/Jan/2019 21:10:14] "GET /v0.1/device//setting HTTP/1.1" 404 -
127.0.0.1 - - [16/Jan/2019 21:10:14] "GET /v0.1/device/ HTTP/1.1" 404 -

Use more normal pathing?

Software configs for linux tend to go into /etc. Mycroft itself already looks into /etc/mycroft/ for local configs. Mycroft is also using /opt/mycroft. Instead of hiding things in .mycroft, why not use one of those two?

make python package executable

entry points should be added to setup.py to start backend and frontend from command line

in current state package needs to be imported and executed as shown in examples folder

start_backend.py not work

I'm trying to run the bakend but i get this response:

~/Documentos/Proyectos/api$ python3.6 examples/start_backend.py
Traceback (most recent call last):
  File "examples/start_backend.py", line 5, in <module>
    start_backend()
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/backend/__init__.py", line 70, in start_backend
    app = create_app()
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/backend/__init__.py", line 41, in create_app
    from personal_mycroft_backend.backend.stt import get_stt_routes
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/backend/stt.py", line 25, in <module>
    engine = STTFactory.create()
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/__init__.py", line 228, in create
    return clazz()
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/__init__.py", line 74, in __init__
    super(GoogleSTT, self).__init__()
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/__init__.py", line 42, in __init__
    super(TokenSTT, self).__init__()
  File "/home/andres/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/__init__.py", line 30, in __init__
    self.credential = self.config.get("credential", {})
AttributeError: 'NoneType' object has no attribute 'get'

Someone can help me with that?

Dockerize Software

Hey I was wondering if there were plans to dockerize the components required to run this backend? Thanks!

secret key and salt

Hi,
Decided to have go getting this running, however I can't workout
where secret key and salt are coming from

I've had a look in some of the files and still can't work it out

I could use some guidance
Best Regards
dragonsKnight5

Login failures

When using the login form at the upper right and submitting valid credentials, I get the following in the log for the frontend:

[2019-01-24 22:03:22,098] ERROR in app: Exception on / [POST]
Traceback (most recent call last):
  File "/home/olympus/.local/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/olympus/.local/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/olympus/.local/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/olympus/.local/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/olympus/.local/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/olympus/.local/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/olympus/personal-backend/personal_mycroft_backend/backend/decorators.py", line 14, in decorated_function
    resp = make_response(f(*args, **kwargs))
  File "/home/olympus/personal-backend/personal_mycroft_backend/backend/decorators.py", line 14, in decorated_function
    resp = make_response(f(*args, **kwargs))
  File "/home/olympus/personal-backend/personal_mycroft_backend/frontend/main.py", line 29, in login
    if utils.credentials_valid(username, password):
  File "/home/olympus/personal-backend/personal_mycroft_backend/frontend/utils.py", line 88, in credentials_valid
    return bcrypt.checkpw(password.encode('utf8'), user.password.encode('utf8'))
AttributeError: 'bytes' object has no attribute 'encode'
192.168.1.1 - - [24/Jan/2019 22:03:15] "POST / HTTP/1.1" 500 -

When submitting bogus credentials, it returns a 200 in the logs and no error on the browser side.

Anyone else seeing this?

Privacy improvements

The current code could be more privacy friendly. Issues:

  • A connection is made to https://ipapi.co/json/ in backend utils. Solution: assume a country code. Not the end of the world?
  • The HTML that flask generates tries to download bulma and font_awesome from a CDN. Solution: store these files locally.

Cannot start backend

Howdy, I am unable to launch the back end in python 2 or 3.

I have attempted using the specified "personal_backend.conf" and the auto created version, with the same error:

robot@robot-AI:~/personal-backend/examples$ python3 start_backend.py
Traceback (most recent call last):
File "start_backend.py", line 5, in
start_backend()
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/backend/init.py", line 70, in start_backend
app = create_app()
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/backend/init.py", line 41, in create_app
from personal_mycroft_backend.backend.stt import get_stt_routes
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/backend/stt.py", line 25, in
engine = STTFactory.create()
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/init.py", line 228, in create
return clazz()
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/init.py", line 74, in init
super(GoogleSTT, self).init()
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/init.py", line 42, in init
super(TokenSTT, self).init()
File "/home/robot/.local/lib/python3.6/site-packages/personal_mycroft_backend/stt/init.py", line 30, in init
self.credential = self.config.get("credential", {})
AttributeError: 'NoneType' object has no attribute 'get'

START

How can i start this backed?

pip package

what should be done about the pip package

i think it no longer makes sense for me to be the maintainer of it, it is currently under my account

localhost geolocation fails

when running on same machine (localhost) geolocation will produce incomplete dict, country code will be missing and there are extra unexpected arguments further down the line

sql session badly handled

sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) SQLite objects created in a thread can only be used in that same thread.The object was created in thread id -1249903808 and this is thread id -1262486720 [SQL: 'SELECT devices.uuid AS devices_uuid, devices.created_at AS devices_created_at, devices.description AS devices_description, devices.name AS devices_name, devices.last_seen AS devices_last_seen, devices.expires_at AS devices_expires_at, devices."accessToken" AS "devices_accessToken", devices."refreshToken" AS "devices_refreshToken", devices.paired AS devices_paired, devices.subscription AS devices_subscription, devices.arch AS devices_arch, devices.user_id AS devices_user_id \nFROM devices \nWHERE devices.uuid = ?\n LIMIT ? OFFSET ?'] [parameters: [{}]] (Background on this error at: http://sqlalche.me/e/f405)

Debian packages required

For installation on a RPi3 with Debian (Stretch or Jessie) I had to add some packages before installation completed successfully:
sudo apt-get install python-dev python3-dev libffi-dev libssl-dev

SLL handshake error?

If I start mycroft pointed at the local server, I get a TLS error:

./start-mycroft.sh debug
Already up to date.
Starting all mycroft-core services
Initializing...
Starting cli
12:27:59.603 - mycroft.api:is_paired:514 - WARNING - Could not get device info: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'0.0.0.0\', port=6712): Max retries exceeded with url: /v0.1/device/ (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'tls_process_server_certificate\', \'certificate verify failed\')])")))'))

It seems Mycroft doesn't like self-signed certificates? How can that be changed?

New account creation requires email

Thinking this would be handled better via a local config or utility.
Might be useful to create a 1st run script that does a bit of this (cert setup, admin account creation) perhaps.

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.