From fbdba9bfdd1563479ce20a25aa6d88b4f02c510b Mon Sep 17 00:00:00 2001 From: "Matthew D. Scholefield" Date: Thu, 29 Mar 2018 02:23:15 -0500 Subject: [PATCH] Update runner README and improve Python 2 support --- runner/README.md | 28 +++++++++++++++++++++++++++- runner/precise_runner/runner.py | 4 ++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/runner/README.md b/runner/README.md index 1836d08..e0c36e2 100644 --- a/runner/README.md +++ b/runner/README.md @@ -1,3 +1,29 @@ # Precise Wrapper -A simple to use \ No newline at end of file +A simple to use, lightweight Python module for using Mycroft Precise. + +## Usage: + +First, download the precise binary from [the precise-data repo][precise-data]. +Next, extract the tar to the folder of your choice. The following commands will +work for a desktop: + +[precise-data]: https://github.com/mycroftai/precise-data/tree/dist + +```bash +ARCH=x86_64 +wget https://github.com/MycroftAI/precise-data/raw/dist/$ARCH/precise-engine.tar.gz +tar xvf precise-engine.tar.gz +``` + +Finally, you can create a program as follows, passing in the location of +the executable as the first argument: + +```python +#!/usr/bin/env python3 + +from precise_runner import PreciseEngine, PreciseRunner + +engine = PreciseEngine('precise-engine/precise-engine', 'my_model_file.pb') +runner = PreciseRunner(engine, on_activation=lambda: print('hello')) +``` diff --git a/runner/precise_runner/runner.py b/runner/precise_runner/runner.py index df8e120..30ed5e3 100644 --- a/runner/precise_runner/runner.py +++ b/runner/precise_runner/runner.py @@ -71,7 +71,7 @@ class ListenerEngine(Engine): self.get_prediction = listener.update -class ReadWriteStream: +class ReadWriteStream(object): """Class used to support writing binary audio data at any pace""" def __init__(self, s=b''): self.buffer = s @@ -92,7 +92,7 @@ class ReadWriteStream: self.write_event.set() -class PreciseRunner: +class PreciseRunner(object): """ Wrapper to use Precise. Example: >>> def on_act():