Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
f9e2177
Trying support for Windows speech recognition engine
joshuashort Nov 20, 2016
065e0b1
Create HACKING file to collect ideas from codebase
joshuashort Nov 27, 2016
357b7ce
Use metavars in command processing; add simple debug option
joshuashort Nov 27, 2016
761a9ef
Remove number processing and history logging
joshuashort Nov 27, 2016
ba8e49d
Commands isn’t used in the recognizer
joshuashort Nov 27, 2016
54acf15
Remove hashing/updated references from language module
joshuashort Nov 27, 2016
4510351
Split LanguageUpdater into helper functions
joshuashort Dec 3, 2016
53f4714
More debugging; pass recognition to valid/invalid commands; pocketsph…
joshuashort Dec 3, 2016
a8e7c4b
Prototype database for commands/prompts
joshuashort Dec 3, 2016
3db5352
Merge branch 'database-commands' into master-database
joshuashort Dec 5, 2016
8942a38
Merge branch 'windows-recognizer' into master-database
joshuashort Dec 5, 2016
6a32f45
More general auto detect syntax — works on Ubuntu and macOS
joshuashort Dec 9, 2016
709f85f
Merge branch 'master' of https://github.com/vavrek/openassistant into…
joshuashort Dec 18, 2016
7a303e6
The database is in cache for now
joshuashort Dec 19, 2016
ca7a7fc
Command line switch for updating language files
joshuashort Jan 5, 2017
ee08b9d
Trying to reestablish a baseline (commenting out some partial feature…
joshuashort Mar 15, 2018
01ffcc1
Latest README from vavrek/openassistant
joshuashort Mar 15, 2018
bead200
Updating with github-generated python ignore template
joshuashort Mar 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 84 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# OA files
mind/**/cache

# Byte-compiled / optimized / DLL files
__pycache__/
*.pyc
.idea/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
Expand All @@ -16,8 +23,82 @@ lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

mind/**/cache
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
6 changes: 6 additions & 0 deletions HACKING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Speech Recognizer


Generate an fsg file from jsgf

```sphinx_jsgf2fsg < conf.jsgf_file > conf.fsg_file```
54 changes: 8 additions & 46 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Open Assistant
=============

Open Assistant is an evolving open source artificial intelligence agent able
Open Assistant is an evolving open source artificial intelligence agent able
to interact in basic conversation and automate an increasing number of tasks.

Maintained by the `Open Assistant <http://www.openassistant.org/>`__
working group lead by `Andrew Vavrek <https://youtu.be/cXqEv2OVwHE>`__, this software
is an extension of `Blather <https://gitlab.com/jezra/blather>`__
by `Jezra <http://www.jezra.net/>`__, `Kaylee <https://github.com/Ratfink/kaylee>`__
by `Clayton G. Hobbs <https://bzratfink.wordpress.com/>`__, and includes work
Maintained by the `Open Assistant <http://www.openassistant.org/>`__
working group lead by `Andrew Vavrek <https://youtu.be/cXqEv2OVwHE>`__, this software
is an extension of `Blather <https://gitlab.com/jezra/blather>`__
by `Jezra <http://www.jezra.net/>`__, `Kaylee <https://github.com/Ratfink/kaylee>`__
by `Clayton G. Hobbs <https://bzratfink.wordpress.com/>`__, and includes work
done by `Jonathan Kulp <http://jonathankulp.org/>`__.


Expand All @@ -30,15 +30,12 @@ Useful Tools
* aplay - console audio player
* plaympeg - console mp3 player
* projectm - visualizations responsive to sound
* wmctrl - window manager control. opening, closing, resize, switch windows.
* wmctrl - window manager control. opening, closing, resize, switch windows.
* xdotool - command line x automation tool
* xvkbd - virtual keyboard for x

Running OpenAssistant
Running Open Assistant
---------------------
* The latest documentation can be found on our wiki at http://openassistant.org/wiki/

* Install dependencies and tools. Please see http://openassistant.org/wiki/doku.php?id=installation

* Download and unpack the latest ``openassistant-master.zip`` package.

Expand All @@ -54,41 +51,6 @@ Running OpenAssistant

* To change assistant commands and language, edit ``conf/commands.json``. Exit and relaunch ``run.sh``.

* For usage instructions, check out the `Open Assistant Wiki <http://openassistant.org/wiki/doku.php?id=usage>`_.

* For help, you can receive support in the `Open Assistant Forum <http://openassistant.org/community/>`_.


Next Steps
----------

* Port Open Assistant to multiple Linux distributions, beginning with Ubuntu

* Enable dynamic voice and instant name changes via spoken commands

* Configure syntax and actions via spoken commands

* Install internal language model translation

* Improve speech recognition and synthesis

* Long-term memory & machine learning

* Web scraping & information analysis

* Establish multiple default 'personalities' and plug-in functions

* Port Open Assistant to all operating systems and devices

* Galactic Exploration!


Join Us!
--------

Join our development working group at: http://www.openassistant.org
Developers: here's a quick start guide: http://openassistant.org/wiki/doku.php?id=developers


Open Assistant Fork
==================
Expand Down
18 changes: 12 additions & 6 deletions core/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Config:

def __init__(self, path=None, **opts):
logger.info("Loading Mind: {path}".format(path=path))

# DIRECTORIES
self.cache_dir = os.path.join(path, 'cache')
self.conf_dir = os.path.join(path, 'conf')
Expand All @@ -25,9 +25,13 @@ def __init__(self, path=None, **opts):

self._make_dir(self.conf_dir)
self._make_dir(self.cache_dir)

self.options = self._read_options_file()
self.options.update(opts)
logger.info("Options: {}".format(self.options))

self.commands = self._read_commands_file()
logger.info("Command Count: {}".format(len(self.commands)))


def _make_dir(self, directory):
Expand All @@ -37,21 +41,23 @@ def _make_dir(self, directory):

def _read_options_file(self):
try:
logger.debug("Reading options from {}".format(self.opt_file))
with open(self.opt_file, 'r') as f:
_options = json.load(f)
return _options
except FileNotFoundError:
# MAKE AN EMPTY OPTIONS NAMESPACE
logger.warn("Error loading options file: {path}".format(path=self.opt_file))
logger.warn("Error reading options file: {path}".format(path=self.opt_file))
return {}


def _read_commands_file(self):
try:
logger.debug("Reading commands from {}".format(self.cmd_file))
with open(self.cmd_file, 'r') as f:
_cmds = json.load(f)
return _cmds
except FileNotFoundError:
# MAKE AN EMPTY OPTIONS NAMESPACE
logger.warn("Error loading commands file: {path}".format(path=self.cmd_file))
return {}
# MAKE AN EMPTY COMMANDS NAMESPACE
logger.warn("Error reading commands file: {path}".format(path=self.cmd_file))
return {}
47 changes: 47 additions & 0 deletions core/util/db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import sqlite3
import json

#from importlib import reload


class DB:
def __init__(self, path=None):
self.path = ":memory:" if path is None else path
self.db = sqlite3.connect(self.path)

def create_schema(self):
self.db.execute("CREATE TABLE IF NOT EXISTS Prompt (Prompt TEXT)")
self.db.execute("CREATE TABLE IF NOT EXISTS Command (Command TEXT)")
self.db.execute("CREATE TABLE IF NOT EXISTS PromptCommand (PromptID INT, CommandID INT)")
self.db.commit()

def add_action(self, prompt, command):
p = self.db.execute("SELECT rowid FROM Prompt WHERE Prompt = ?", (prompt,)).fetchone()
if p is None:
prompt_id = self.db.execute("INSERT INTO Prompt (Prompt) VALUES (?)", (prompt,)).lastrowid
else:
prompt_id = p[0]

c = self.db.execute("SELECT Command FROM Command WHERE Command = ?", (command,)).fetchone()
if c is None:
command_id = self.db.execute("INSERT INTO Command (Command) VALUES (?)", (command,)).lastrowid
else:
command_id = c[0]

action_id = self.db.execute("SELECT PromptID, CommandID FROM PromptCommand WHERE PromptID=? AND CommandID=?", (prompt_id, command_id)).fetchone()
if action_id is None:
self.db.execute("INSERT INTO PromptCommand (PromptID, CommandID) VALUES (?, ?)", (prompt_id, command_id))

self.db.commit()

def get_action(self, prompt):
action = self.db.execute("SELECT Command FROM Command INNER JOIN PromptCommand ON PromptCommand.CommandID = Command.rowid INNER JOIN Prompt ON Prompt.rowid = PromptCommand.rowid WHERE Prompt = ?", (prompt,)).fetchone()
if action is not None:
return action[0]

def get_prompts(self):
for prompt in self.db.execute("SELECT Prompt FROM Prompt"):
yield prompt[0]

def load_commands(self, path):
pass
55 changes: 51 additions & 4 deletions modules/language/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#from .hasher import Hasher


NET_TEST_SERVER = "http://www.speech.cs.cmu.edu"


class LanguageUpdater:
"""
Handles updating the language using the online lmtool.
Expand All @@ -25,7 +25,7 @@ class LanguageUpdater:
def __init__(self, config):
self.config = config
self.create_strings_file()

#self.hasher = Hasher(config)

# def update_language_if_changed(self):
Expand All @@ -52,15 +52,55 @@ def __init__(self, config):
# self.new_hash = hasher.hexdigest()
#
# return self.new_hash != self.stored_hash



# def create_strings_file(path, source={}):
def create_strings_file(self):
# Open Strings File
# with open(path, 'w+') as strings:
with open(self.config.strings_file, 'w') as strings:
# Add Command Words To The Corpus
# for cmd in source:
# strings.write(cmd.strip().replace('%d', '') + "\n")
for voice_cmd in sorted(self.config.commands.keys()):
strings.write(voice_cmd.strip().replace('%d', '') + "\n")

# def create_sphinx_files(source, lm_path, dic_path):
# """Update the language using the online lmtool"""
# logger.debug("\x1b[32mUpdating Language\x1b[0m")
#
# host = 'http://www.speech.cs.cmu.edu'
# url = host + '/cgi-bin/tools/lmtool/run'
#
# # SUBMIT THE CORPUS TO THE LMTOOL
# response_text = ""
# with open(source, 'rb') as corpus:
# files = {'corpus': corpus}
# values = {'formtype': 'simple'}
#
# r = requests.post(url, files=files, data=values)
# response_text = r.text
#
# # PARSE RESPONSE TO GET URLS OF THE FILES WE NEED
# path_re = r'.*<title>Index of (.*?)</title>.*'
# number_re = r'.*TAR([0-9]*?)\.tgz.*'
# for line in response_text.split('\n'):
# # ERROR RESPONSE
# if "[_ERRO_]" in line:
# return 1
# # IF WE FOUND THE DIRECTORY, KEEP IT AND DON'T BREAK
# if re.search(path_re, line):
# path = host + re.sub(path_re, r'\1', line)
# # IF WE FOUND THE NUMBER, KEEP IT AND BREAK
# elif re.search(number_re, line):
# number = re.sub(number_re, r'\1', line)
# break
#
# lm_url = path + '/' + number + '.lm'
# dic_url = path + '/' + number + '.dic'
#
# _download_file(lm_url, lm_path)
# _download_file(dic_url, dic_path)

def update_language(self):
"""Update the language using the online lmtool"""
Expand Down Expand Up @@ -109,4 +149,11 @@ def _download_file(self, url, path):
if r.status_code == 200:
with open(path, 'wb') as f:
for chunk in r:
f.write(chunk)
f.write(chunk)

# def _download_file(url, dest):
# r = requests.get(url, stream=True)
# if r.status_code == 200:
# with open(dest, 'wb') as f:
# for chunk in r:
# f.write(chunk)
Loading