forked from synesthesiam/hassio-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic web interface for snowboy, precise addons
- Loading branch information
1 parent
cfc298c
commit 3db3e3c
Showing
13 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import json | ||
from uuid import uuid4 | ||
|
||
from flask import Flask, request, send_file, render_template | ||
|
||
app = Flask('mycroft-precise', template_folder='.') | ||
app.secret_key = str(uuid4()) | ||
|
||
config_path = os.environ.get('CONFIG_PATH', '/data/options.json') | ||
model_path = os.environ.get('MODEL_PATH', '/models') | ||
|
||
@app.route('/', methods=['GET', 'POST']) | ||
def index(): | ||
if request.method == 'POST': | ||
if 'delete' in request.form: | ||
model_name = request.form['model'] | ||
os.unlink(os.path.join(model_path, model_name)) | ||
elif 'file' in request.files: | ||
file = request.files['file'] | ||
model_name = file.filename | ||
file.save(os.path.join(model_path, model_name)) | ||
|
||
with open(config_path, 'r') as config_file: | ||
config = json.load(config_file) | ||
|
||
models = [] | ||
if os.path.exists(model_path): | ||
for model_name in os.listdir(model_path): | ||
models.append(os.path.join(model_path, model_name)) | ||
|
||
return render_template('index.html', config=config, models=models) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
|
||
<title>Mycroft Precise (Rhasspy)</title> | ||
</head> | ||
<body> | ||
<h1>Mycroft Precise for Rhasspy</h1> | ||
<p> | ||
Wake word detection for the <a href="https://github.com/synesthesiam/rhasspy-hassio-addon/">Rhasspy voice assistant</a> with <a href="https://github.com/MycroftAI/mycroft-precise">Mycroft Precise</a>. | ||
</p> | ||
|
||
<hr> | ||
|
||
<h2>Models</h2> | ||
<form method="post" action="/" enctype="multipart/form-data"> | ||
<input type="file" name="file"> | ||
<input type="submit" value="Upload Model"> | ||
</form> | ||
<br> | ||
|
||
<form method="post" action="/" onsubmit="return confirm('Are you sure?');"> | ||
<input type="hidden" name="delete" value="1"> | ||
<table> | ||
<thead> | ||
<th>Model</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{% for model in models %} | ||
<tr> | ||
<td>{{ model }}</td> | ||
<td> | ||
<button type="submit" name="model" value="{{ model }}">Delete</button> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</form> | ||
|
||
<hr> | ||
|
||
<h2>Configuration</h2> | ||
<p> | ||
{{ config }} | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
import json | ||
from uuid import uuid4 | ||
|
||
from flask import Flask, request, send_file, render_template | ||
|
||
app = Flask('mycroft-precise', template_folder='.') | ||
app.secret_key = str(uuid4()) | ||
|
||
config_path = os.environ.get('CONFIG_PATH', '/data/options.json') | ||
model_path = os.environ.get('MODEL_PATH', '/models') | ||
|
||
@app.route('/', methods=['GET', 'POST']) | ||
def index(): | ||
if request.method == 'POST': | ||
if 'delete' in request.form: | ||
model_name = request.form['model'] | ||
os.unlink(os.path.join(model_path, model_name)) | ||
elif 'file' in request.files: | ||
file = request.files['file'] | ||
model_name = file.filename | ||
file.save(os.path.join(model_path, model_name)) | ||
|
||
with open(config_path, 'r') as config_file: | ||
config = json.load(config_file) | ||
|
||
models = [] | ||
if os.path.exists(model_path): | ||
for model_name in os.listdir(model_path): | ||
models.append(os.path.join(model_path, model_name)) | ||
|
||
return render_template('index.html', config=config, models=models) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
|
||
<title>Snowboy (Rhasspy)</title> | ||
</head> | ||
<body> | ||
<h1>Snowboy for Rhasspy</h1> | ||
<p> | ||
Wake word detection for the <a href="https://github.com/synesthesiam/rhasspy-hassio-addon/">Rhasspy voice assistant</a> with <a href="https://snowboy.kitt.ai/">Snowboy</a>. | ||
</p> | ||
|
||
<hr> | ||
|
||
<h2>Models</h2> | ||
<form method="post" action="/" enctype="multipart/form-data"> | ||
<input type="file" name="file"> | ||
<input type="submit" value="Upload Model"> | ||
</form> | ||
<br> | ||
|
||
<form method="post" action="/" onsubmit="return confirm('Are you sure?');"> | ||
<input type="hidden" name="delete" value="1"> | ||
<table> | ||
<thead> | ||
<th>Model</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{% for model in models %} | ||
<tr> | ||
<td>{{ model }}</td> | ||
<td> | ||
<button type="submit" name="model" value="{{ model }}">Delete</button> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</form> | ||
|
||
<hr> | ||
|
||
<h2>Configuration</h2> | ||
<p> | ||
{{ config }} | ||
</p> | ||
</body> | ||
</html> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters