Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 04efe9f151 | |||
| 2cac48292a | |||
| a4528d40fb | |||
| 4cd8b307c7 | |||
| de0824e49a | |||
| 74ba8c1c4a | |||
| 9428abdd40 | |||
| a6c425d65f | |||
| 015c37fa5d | |||
| 32f7e37657 | |||
| 54063feb03 | |||
| 3bc36f2fb1 | |||
| e0401d4c18 | |||
| 73124075ae | |||
| c410f4eea7 | |||
| 3f0545ed0f | |||
| 331138f300 | |||
| 33b847b828 | |||
| d770679373 | |||
| 86e695a7a4 | |||
| 07d1cc4e43 | |||
| b68e5caf01 | |||
| da4d994e75 | |||
| 627e6e8b3d | |||
| f0ec0486f7 | |||
| 1febc3d1d8 | |||
| 2879802f2f | |||
| 21a2a8f9b4 | |||
| a96f80237e | |||
| fc68d04f29 | |||
| e00c1448cb | |||
| f04ad3bfeb | |||
| eb11f90cab | |||
| 2c612ee669 | |||
| dfe92f9d0e | |||
| c59e7b42ab | |||
| 948705a87b | |||
| 6b0b5c1799 | |||
| 9553691e88 | |||
| 997456631e | |||
| 104165198b | |||
| f405b827f4 | |||
| 089568cf9f |
+7
-6
@@ -1,14 +1,13 @@
|
||||
*
|
||||
!etc/qemu-*
|
||||
|
||||
!download/rhasspy-tools*
|
||||
!download/pocketsphinx-python.tar.gz
|
||||
!download/snowboy*
|
||||
!download/kaldi*
|
||||
!download/
|
||||
|
||||
!requirements.txt
|
||||
!dist/
|
||||
!etc/wav
|
||||
!etc/shflags
|
||||
!create-venv.sh
|
||||
!download-dependencies.sh
|
||||
|
||||
!docker/run.sh
|
||||
!docker/rhasspy
|
||||
@@ -172,4 +171,6 @@
|
||||
!rhasspy/train/*.py
|
||||
!rhasspy/train/jsgf2fst/*.py
|
||||
!*.py
|
||||
!VERSION
|
||||
!VERSION
|
||||
|
||||
!pip
|
||||
|
||||
@@ -1,12 +1,60 @@
|
||||
## [Unreleased] - 2020 Jan 21
|
||||
## [2.4.20] - 2020 Apr 10
|
||||
|
||||
### Added
|
||||
|
||||
- Button to web UI to play last recorded voice commmand
|
||||
- RHASSPY_LOG_LEVEL environment variable
|
||||
- Web UI feedback during download
|
||||
- libasound2-plugins to Docker image (for Hass.IO)
|
||||
- MQTT TLS support (thanks https://github.com/ofekd)
|
||||
- Mycroft Precise 0.3.0 added to Docker image
|
||||
|
||||
### Changed
|
||||
|
||||
- Properly accept websocket connections
|
||||
- Don't error out on missing porcupine files
|
||||
- Fix rawValue in MQTT messages
|
||||
|
||||
## [2.4.19] - 2020 Mar 04
|
||||
|
||||
### Added
|
||||
|
||||
- Support for Google Cloud speech to text
|
||||
- Rasa NLU minimum confidence parameter
|
||||
|
||||
### Changed
|
||||
|
||||
- Using tagged version of porcupine wake models to avoid incompatibilities
|
||||
- Fix Rasa NLU first entity only bug
|
||||
- Fix siteId null bug
|
||||
|
||||
## [2.4.18] - 2020 Feb 07
|
||||
|
||||
### Added
|
||||
|
||||
- /api/listen-for-wake accepts "on" and "off" as POST data to enable/disable wake word
|
||||
- /api/events/wake websocket endpoint reports wake up events
|
||||
- /api/events/text websocket endpoint reports transcription events
|
||||
- Rhasspy logo changes in web UI when wake word is detected
|
||||
- espeak arguments list for text to speech
|
||||
|
||||
### Changed
|
||||
|
||||
- STT output casing is fixed outside of HTTP API calls
|
||||
- All voice commands show up in web UI test page
|
||||
- Play last voice command button in web UI works for any command
|
||||
- Fixed commas in numbers with thousand separators
|
||||
- Words from Pocketsphinx wake keyphrase are added to dictionary
|
||||
- Pocketsphinx wake word keyphrase casing is fixed
|
||||
|
||||
## [2.4.17] - 2020 Jan 21
|
||||
|
||||
### Added
|
||||
|
||||
- Button to web UI to play last recorded voice command
|
||||
- RHASSPY_LOG_LEVEL environment variable
|
||||
- Web UI feedback during download
|
||||
- Add "asoundrc" config option to Hass.IO add-on
|
||||
|
||||
### Changed
|
||||
|
||||
- Moved $profile/kaldi/custom_words.txt to $profile/kaldi_custom_words.txt
|
||||
- Slot substitution casing is kept during training/recognition
|
||||
- Fixed fuzzywuzzy and other intent recognizer training after addition of converters
|
||||
@@ -33,7 +81,7 @@
|
||||
|
||||
### Added
|
||||
|
||||
- Preliminary support for Rasperry Pi Zero (no Kaldi)
|
||||
- Preliminary support for Raspberry Pi Zero (no Kaldi)
|
||||
- Play error sound when intent not recognized
|
||||
- _text and _raw_text to Home Assistant events
|
||||
|
||||
@@ -53,4 +101,4 @@
|
||||
- Support for Home Assistant TTS system
|
||||
- Emulate MaryTTS /process API in web API
|
||||
- Include wakeId/siteId in JSON intent (MQTT/Websocket)
|
||||
- ?voice and ?language query parameters to /api/text-to-speech
|
||||
- ?voice and ?language query parameters to /api/text-to-speech
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
FROM ubuntu:eoan as build
|
||||
ARG TARGETPLATFORM
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV RHASSPY_APP /usr/share/rhasspy
|
||||
ENV RHASSPY_VENV ${RHASSPY_APP}/.venv
|
||||
|
||||
WORKDIR /
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install --no-install-recommends --yes \
|
||||
python3 python3-dev python3-setuptools python3-pip python3-venv \
|
||||
build-essential swig portaudio19-dev libatlas-base-dev
|
||||
|
||||
COPY etc/shflags ${RHASSPY_APP}/etc/
|
||||
COPY download/rhasspy-tools_*.tar.gz \
|
||||
download/kaldi_*.tar.gz \
|
||||
download/pocketsphinx-python.tar.gz \
|
||||
download/snowboy-1.3.0.tar.gz \
|
||||
download/precise-engine_0.3.0_*.tar.gz \
|
||||
${RHASSPY_APP}/download/
|
||||
COPY create-venv.sh download-dependencies.sh requirements.txt ${RHASSPY_APP}/
|
||||
RUN cd ${RHASSPY_APP} && ./create-venv.sh --nosystem --noweb
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
FROM ubuntu:eoan
|
||||
ARG TARGETPLATFORM
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV RHASSPY_APP /usr/share/rhasspy
|
||||
ENV RHASSPY_VENV ${RHASSPY_APP}/.venv
|
||||
|
||||
WORKDIR /
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install --no-install-recommends --yes \
|
||||
python3 python3-dev \
|
||||
bash jq unzip curl perl \
|
||||
libportaudio2 libatlas3-base \
|
||||
libgfortran4 ca-certificates \
|
||||
sox espeak flite libttspico-utils alsa-utils lame \
|
||||
libasound2-plugins \
|
||||
libfreetype6-dev libpng-dev pkg-config libffi-dev libssl-dev \
|
||||
gstreamer1.0-tools gstreamer1.0-plugins-good
|
||||
|
||||
COPY --from=build ${RHASSPY_VENV} ${RHASSPY_VENV}
|
||||
COPY --from=build ${RHASSPY_APP}/opt/kaldi/ ${RHASSPY_APP}/opt/kaldi/
|
||||
|
||||
# Web interface
|
||||
ADD download/rhasspy-web-dist.tar.gz ${RHASSPY_APP}/
|
||||
|
||||
RUN ldconfig
|
||||
|
||||
# Copy script to run
|
||||
COPY docker/run.sh /run.sh
|
||||
RUN chmod +x /run.sh
|
||||
|
||||
COPY profiles/ ${RHASSPY_APP}/profiles/
|
||||
|
||||
COPY profiles/defaults.json ${RHASSPY_APP}/profiles/
|
||||
COPY docker/rhasspy ${RHASSPY_APP}/bin/
|
||||
COPY dist/ ${RHASSPY_APP}/dist/
|
||||
COPY etc/wav/* ${RHASSPY_APP}/etc/wav/
|
||||
COPY rhasspy/profile_schema.json ${RHASSPY_APP}/rhasspy/
|
||||
COPY rhasspy/train/jsgf2fst/*.py ${RHASSPY_APP}/rhasspy/train/jsgf2fst/
|
||||
COPY rhasspy/train/*.py ${RHASSPY_APP}/rhasspy/train/
|
||||
COPY *.py ${RHASSPY_APP}/
|
||||
COPY rhasspy/*.py ${RHASSPY_APP}/rhasspy/
|
||||
COPY VERSION ${RHASSPY_APP}/
|
||||
|
||||
ENV CONFIG_PATH /data/options.json
|
||||
ENV KALDI_PREFIX ${RHASSPY_APP}/opt
|
||||
|
||||
ENTRYPOINT ["/run.sh"]
|
||||
@@ -1,49 +1,17 @@
|
||||
.PHONY: web-dist docker manifest docs-uml g2p check
|
||||
SHELL := bash
|
||||
|
||||
DOCKER_PLATFORMS = linux/amd64,linux/arm64,linux/arm/v7
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Docker
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
docker: web-dist docker-amd64 docker-armhf docker-aarch64
|
||||
|
||||
docker-deploy: docker-push manifest
|
||||
|
||||
docker-amd64:
|
||||
docker build . -f docker/templates/dockerfiles/Dockerfile.prebuilt.alsa.all \
|
||||
--build-arg BUILD_ARCH=amd64 \
|
||||
--build-arg CPU_ARCH=x86_64 \
|
||||
--build-arg BUILD_FROM=ubuntu:bionic \
|
||||
-t synesthesiam/rhasspy-server:amd64
|
||||
|
||||
docker-armhf:
|
||||
docker build . -f docker/templates/dockerfiles/Dockerfile.prebuilt.alsa.all \
|
||||
--build-arg BUILD_ARCH=armhf \
|
||||
--build-arg CPU_ARCH=armv7l \
|
||||
--build-arg BUILD_FROM=arm32v7/ubuntu:bionic \
|
||||
-t synesthesiam/rhasspy-server:armhf
|
||||
|
||||
docker-aarch64:
|
||||
docker build . -f docker/templates/dockerfiles/Dockerfile.prebuilt.alsa.all \
|
||||
--build-arg BUILD_ARCH=aarch64 \
|
||||
--build-arg CPU_ARCH=arm64v8 \
|
||||
--build-arg BUILD_FROM=arm64v8/ubuntu:bionic \
|
||||
-t synesthesiam/rhasspy-server:aarch64
|
||||
|
||||
docker-push:
|
||||
docker push synesthesiam/rhasspy-server:amd64
|
||||
docker push synesthesiam/rhasspy-server:armhf
|
||||
docker push synesthesiam/rhasspy-server:aarch64
|
||||
|
||||
manifest:
|
||||
docker manifest push --purge synesthesiam/rhasspy-server:latest
|
||||
docker manifest create --amend synesthesiam/rhasspy-server:latest \
|
||||
synesthesiam/rhasspy-server:amd64 \
|
||||
synesthesiam/rhasspy-server:armhf \
|
||||
synesthesiam/rhasspy-server:aarch64
|
||||
docker manifest annotate synesthesiam/rhasspy-server:latest synesthesiam/rhasspy-server:armhf --os linux --arch arm
|
||||
docker manifest annotate synesthesiam/rhasspy-server:latest synesthesiam/rhasspy-server:aarch64 --os linux --arch arm64
|
||||
docker manifest push synesthesiam/rhasspy-server:latest
|
||||
docker: web-dist
|
||||
docker buildx build . \
|
||||
--platform $(DOCKER_PLATFORMS) \
|
||||
--tag rhasspy/rhasspy-server:latest \
|
||||
--push
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Yarn (Vue)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
Rhasspy (pronounced RAH-SPEE) is an offline, [multilingual](#supported-languages) voice assistant toolkit inspired by [Jasper](https://jasperproject.github.io/) that works well with [Home Assistant](https://www.home-assistant.io/), [Hass.io](https://www.home-assistant.io/hassio/), and [Node-RED](https://nodered.org).
|
||||
Rhasspy (pronounced RAH-SPEE) is an offline voice assistant toolkit inspired by [Jasper](https://jasperproject.github.io/) that [supports many languages](#supported-languages). It works well with [Home Assistant](https://www.home-assistant.io/), [Hass.io](https://www.home-assistant.io/hassio/), and [Node-RED](https://nodered.org).
|
||||
|
||||
* [Documentation](https://rhasspy.readthedocs.io/)
|
||||
* [Discussion](https://community.rhasspy.org)
|
||||
|
||||
@@ -9,8 +9,9 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
||||
from uuid import uuid4
|
||||
|
||||
import attr
|
||||
@@ -30,7 +31,13 @@ from swagger_ui import quart_api_doc
|
||||
|
||||
from rhasspy.actor import ActorSystem, ConfigureEvent, RhasspyActor
|
||||
from rhasspy.core import RhasspyCore
|
||||
from rhasspy.events import IntentRecognized, ProfileTrainingFailed
|
||||
from rhasspy.events import (
|
||||
IntentRecognized,
|
||||
ProfileTrainingFailed,
|
||||
VoiceCommand,
|
||||
WakeWordDetected,
|
||||
WavTranscription,
|
||||
)
|
||||
from rhasspy.utils import (
|
||||
FunctionLoggingHandler,
|
||||
buffer_to_wav,
|
||||
@@ -54,6 +61,10 @@ app = Quart("rhasspy")
|
||||
app.secret_key = str(uuid4())
|
||||
app = cors(app)
|
||||
|
||||
# WAV data from last voice command
|
||||
last_voice_wav: Optional[bytes] = None
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Parse Arguments
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -269,8 +280,11 @@ async def api_speakers() -> Response:
|
||||
async def api_listen_for_wake() -> str:
|
||||
"""Make Rhasspy listen for a wake word"""
|
||||
assert core is not None
|
||||
core.listen_for_wake()
|
||||
return "OK"
|
||||
enabled_str = (await request.data).decode().strip().lower()
|
||||
enabled = enabled_str not in ["false", "off"]
|
||||
core.listen_for_wake(enabled)
|
||||
|
||||
return str(enabled)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -291,6 +305,10 @@ async def api_listen_for_command() -> Response:
|
||||
entity = request.args.get("entity")
|
||||
value = request.args.get("value")
|
||||
|
||||
# Emulate wake
|
||||
wake_json = json.dumps({"wakewordId": "default", "siteId": core.siteId})
|
||||
await add_ws_event("wake", wake_json)
|
||||
|
||||
return jsonify(
|
||||
await core.listen_for_command(
|
||||
handle=(not no_hass), timeout=timeout, entity=entity, value=value
|
||||
@@ -651,6 +669,7 @@ async def api_restart() -> str:
|
||||
@app.route("/api/speech-to-text", methods=["POST"])
|
||||
async def api_speech_to_text() -> str:
|
||||
"""Transcribe speech from WAV file."""
|
||||
global last_voice_wav
|
||||
no_header = request.args.get("noheader", "false").lower() == "true"
|
||||
assert core is not None
|
||||
|
||||
@@ -660,10 +679,20 @@ async def api_speech_to_text() -> str:
|
||||
# Wrap in WAV
|
||||
wav_data = buffer_to_wav(wav_data)
|
||||
|
||||
last_voice_wav = wav_data
|
||||
|
||||
start_time = time.perf_counter()
|
||||
result = await core.transcribe_wav(wav_data)
|
||||
end_time = time.perf_counter()
|
||||
|
||||
# Send to websocket
|
||||
await add_ws_event(
|
||||
"transcription",
|
||||
json.dumps(
|
||||
{"text": result.text, "wakewordId": "default", "siteId": core.siteId}
|
||||
),
|
||||
)
|
||||
|
||||
if prefers_json():
|
||||
return jsonify(
|
||||
{
|
||||
@@ -698,7 +727,7 @@ async def api_text_to_intent():
|
||||
|
||||
intent_json = json.dumps(intent)
|
||||
logger.debug(intent_json)
|
||||
await add_ws_event(WS_EVENT_INTENT, intent_json)
|
||||
await add_ws_event("intent", intent_json)
|
||||
|
||||
if not no_hass:
|
||||
# Send intent to Home Assistant
|
||||
@@ -713,11 +742,13 @@ async def api_text_to_intent():
|
||||
@app.route("/api/speech-to-intent", methods=["POST"])
|
||||
async def api_speech_to_intent() -> Response:
|
||||
"""Transcribe speech, recognize intent, and optionally handle."""
|
||||
global last_voice_wav
|
||||
assert core is not None
|
||||
no_hass = request.args.get("nohass", "false").lower() == "true"
|
||||
|
||||
# Prefer 16-bit 16Khz mono, but will convert with sox if needed
|
||||
wav_data = await request.data
|
||||
last_voice_wav = wav_data
|
||||
|
||||
# speech -> text
|
||||
start_time = time.time()
|
||||
@@ -725,6 +756,12 @@ async def api_speech_to_intent() -> Response:
|
||||
text = transcription.text
|
||||
logger.debug(text)
|
||||
|
||||
# Send to websocket
|
||||
await add_ws_event(
|
||||
"transcription",
|
||||
json.dumps({"text": text, "wakewordId": "default", "siteId": core.siteId}),
|
||||
)
|
||||
|
||||
# text -> intent
|
||||
intent = (await core.recognize_intent(text)).intent
|
||||
intent["speech_confidence"] = transcription.confidence
|
||||
@@ -734,7 +771,7 @@ async def api_speech_to_intent() -> Response:
|
||||
|
||||
intent_json = json.dumps(intent)
|
||||
logger.debug(intent_json)
|
||||
await add_ws_event(WS_EVENT_INTENT, intent_json)
|
||||
await add_ws_event("intent", intent_json)
|
||||
|
||||
if not no_hass:
|
||||
# Send intent to Home Assistant
|
||||
@@ -745,8 +782,6 @@ async def api_speech_to_intent() -> Response:
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
last_voice_wav: Optional[bytes] = None
|
||||
|
||||
|
||||
@app.route("/api/start-recording", methods=["POST"])
|
||||
async def api_start_recording() -> str:
|
||||
@@ -775,12 +810,18 @@ async def api_stop_recording() -> Response:
|
||||
text = transcription.text
|
||||
logger.debug(text)
|
||||
|
||||
# Send to websocket
|
||||
await add_ws_event(
|
||||
"transcription",
|
||||
json.dumps({"text": text, "wakewordId": "default", "siteId": core.siteId}),
|
||||
)
|
||||
|
||||
intent = (await core.recognize_intent(text)).intent
|
||||
intent["speech_confidence"] = transcription.confidence
|
||||
|
||||
intent_json = json.dumps(intent)
|
||||
logger.debug(intent_json)
|
||||
await add_ws_event(WS_EVENT_INTENT, intent_json)
|
||||
await add_ws_event("intent", intent_json)
|
||||
|
||||
if not no_hass:
|
||||
# Send intent to Home Assistant
|
||||
@@ -1115,26 +1156,26 @@ async def swagger_yaml() -> Response:
|
||||
# WebSocket API
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
WS_EVENT_INTENT = 0
|
||||
WS_EVENT_LOG = 1
|
||||
|
||||
ws_queues: List[List[asyncio.Queue]] = [[], []]
|
||||
ws_locks: List[asyncio.Lock] = [asyncio.Lock(), asyncio.Lock()]
|
||||
user_queues: Set[asyncio.Queue] = set()
|
||||
logging_queues: Set[asyncio.Queue] = set()
|
||||
|
||||
|
||||
async def add_ws_event(event_type: int, text: str):
|
||||
"""Send text out to all websockets for a specific event."""
|
||||
async with ws_locks[event_type]:
|
||||
for q in ws_queues[event_type]:
|
||||
await q.put(text)
|
||||
async def add_ws_event(message_type: str, text: str):
|
||||
"""Send text out to all user websockets for a specific event."""
|
||||
for q in user_queues:
|
||||
await q.put((message_type, text))
|
||||
|
||||
|
||||
async def log_ws_event(text: str):
|
||||
"""Send logging message out to websockets."""
|
||||
for q in logging_queues:
|
||||
await q.put(text)
|
||||
|
||||
|
||||
# Send logging messages out to websocket
|
||||
logging.root.addHandler(
|
||||
FunctionLoggingHandler(
|
||||
lambda msg: asyncio.run_coroutine_threadsafe(
|
||||
add_ws_event(WS_EVENT_LOG, msg), loop
|
||||
)
|
||||
lambda msg: asyncio.run_coroutine_threadsafe(log_ws_event(msg), loop)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1144,6 +1185,8 @@ class WebSocketObserver(RhasspyActor):
|
||||
|
||||
def in_started(self, message: Any, sender: RhasspyActor) -> None:
|
||||
"""Handle messages in started state."""
|
||||
global last_voice_wav
|
||||
|
||||
if isinstance(message, IntentRecognized):
|
||||
# Add slots
|
||||
intent_slots = {}
|
||||
@@ -1155,38 +1198,91 @@ class WebSocketObserver(RhasspyActor):
|
||||
# Convert to JSON
|
||||
intent_json = json.dumps(message.intent)
|
||||
self._logger.debug(intent_json)
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
add_ws_event(WS_EVENT_INTENT, intent_json), loop
|
||||
asyncio.run_coroutine_threadsafe(add_ws_event("intent", intent_json), loop)
|
||||
elif isinstance(message, WakeWordDetected):
|
||||
assert core is not None
|
||||
wake_json = json.dumps({"wakewordId": message.name, "siteId": core.siteId})
|
||||
asyncio.run_coroutine_threadsafe(add_ws_event("wake", wake_json), loop)
|
||||
elif isinstance(message, WavTranscription):
|
||||
assert core is not None
|
||||
transcription_json = json.dumps(
|
||||
{
|
||||
"text": message.text,
|
||||
"wakewordId": message.wakewordId,
|
||||
"siteId": core.siteId,
|
||||
}
|
||||
)
|
||||
asyncio.run_coroutine_threadsafe(
|
||||
add_ws_event("transcription_json", transcription_json), loop
|
||||
)
|
||||
elif isinstance(message, VoiceCommand):
|
||||
# Save last voice command
|
||||
last_voice_wav = buffer_to_wav(message.data)
|
||||
|
||||
|
||||
def api_websocket(func):
|
||||
"""Wraps a websocket route to use a user websocket queue"""
|
||||
|
||||
@wraps(func)
|
||||
async def wrapper(*_args, **kwargs):
|
||||
global user_queues
|
||||
queue = asyncio.Queue()
|
||||
user_queues.add(queue)
|
||||
try:
|
||||
return await func(queue, *_args, **kwargs)
|
||||
except Exception:
|
||||
logger.exception("api_websocket")
|
||||
finally:
|
||||
user_queues.discard(queue)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@app.websocket("/api/events/intent")
|
||||
async def api_events_intent() -> None:
|
||||
@api_websocket
|
||||
async def api_events_intent(queue) -> None:
|
||||
"""Websocket endpoint to receive intents as JSON."""
|
||||
# Add new queue for websocket
|
||||
q: asyncio.Queue = asyncio.Queue()
|
||||
async with ws_locks[WS_EVENT_INTENT]:
|
||||
ws_queues[WS_EVENT_INTENT].append(q)
|
||||
await websocket.accept()
|
||||
|
||||
try:
|
||||
while True:
|
||||
text = await q.get()
|
||||
while True:
|
||||
message_type, text = await queue.get()
|
||||
if message_type == "intent":
|
||||
await websocket.send(text)
|
||||
except Exception:
|
||||
logger.exception("api_events_intent")
|
||||
|
||||
# Remove queue
|
||||
async with ws_locks[WS_EVENT_INTENT]:
|
||||
ws_queues[WS_EVENT_INTENT].remove(q)
|
||||
|
||||
@app.websocket("/api/events/text")
|
||||
@api_websocket
|
||||
async def api_events_text(queue) -> None:
|
||||
"""Websocket endpoint for transcriptions."""
|
||||
await websocket.accept()
|
||||
|
||||
while True:
|
||||
message_type, text = await queue.get()
|
||||
if message_type == "transcription":
|
||||
await websocket.send(text)
|
||||
|
||||
|
||||
@app.websocket("/api/events/wake")
|
||||
@api_websocket
|
||||
async def api_events_wake(queue) -> None:
|
||||
"""Websocket endpoint to report wake up."""
|
||||
await websocket.accept()
|
||||
|
||||
while True:
|
||||
message_type, text = await queue.get()
|
||||
if message_type == "wake":
|
||||
await websocket.send(text)
|
||||
|
||||
|
||||
@app.websocket("/api/events/log")
|
||||
async def api_events_log() -> None:
|
||||
"""Websocket endpoint to receive logging messages as text."""
|
||||
await websocket.accept()
|
||||
|
||||
# Add new queue for websocket
|
||||
q: asyncio.Queue = asyncio.Queue()
|
||||
async with ws_locks[WS_EVENT_LOG]:
|
||||
ws_queues[WS_EVENT_LOG].append(q)
|
||||
logging_queues.add(q)
|
||||
|
||||
try:
|
||||
while True:
|
||||
@@ -1196,8 +1292,7 @@ async def api_events_log() -> None:
|
||||
pass
|
||||
|
||||
# Remove queue
|
||||
async with ws_locks[WS_EVENT_LOG]:
|
||||
ws_queues[WS_EVENT_LOG].remove(q)
|
||||
logging_queues.discard(q)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
+31
-9
@@ -11,10 +11,12 @@ DEFINE_string 'venv' "${this_dir}/.venv" 'Path to create virtual environment'
|
||||
DEFINE_string 'download-dir' "${this_dir}/download" 'Directory to cache downloaded files'
|
||||
DEFINE_boolean 'system' true 'Install system dependencies'
|
||||
DEFINE_boolean 'flair' false 'Install flair'
|
||||
DEFINE_boolean 'precise' false 'Install Mycroft Precise'
|
||||
DEFINE_boolean 'precise' true 'Install Mycroft Precise'
|
||||
DEFINE_boolean 'adapt' true 'Install Mycroft Adapt'
|
||||
DEFINE_boolean 'google' false 'Install Google Text to Speech'
|
||||
DEFINE_boolean 'kaldi' true 'Install Kaldi'
|
||||
DEFINE_boolean 'tools' true 'Install Rhasspy tools'
|
||||
DEFINE_boolean 'web' true 'Install web UI'
|
||||
DEFINE_boolean 'offline' false "Don't download anything"
|
||||
DEFINE_integer 'make-threads' 4 'Number of threads to use with make' 'j'
|
||||
DEFINE_string 'python' '' 'Path to Python executable'
|
||||
@@ -60,6 +62,14 @@ if [[ "${FLAGS_offline}" -eq "${FLAGS_TRUE}" ]]; then
|
||||
offline='true'
|
||||
fi
|
||||
|
||||
if [[ "${FLAGS_tools}" -eq "${FLAGS_FALSE}" ]]; then
|
||||
no_tools='true'
|
||||
fi
|
||||
|
||||
if [[ "${FLAGS_web}" -eq "${FLAGS_FALSE}" ]]; then
|
||||
no_web='true'
|
||||
fi
|
||||
|
||||
make_threads="${FLAGS_make_threads}"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -183,6 +193,14 @@ if [[ -n "${no_kaldi}" ]]; then
|
||||
download_args+=('--nokaldi')
|
||||
fi
|
||||
|
||||
if [[ -n "${no_tools}" ]]; then
|
||||
download_args+=('--notools')
|
||||
fi
|
||||
|
||||
if [[ -n "${no_web}" ]]; then
|
||||
download_args+=('--noweb')
|
||||
fi
|
||||
|
||||
bash download-dependencies.sh "${download_args[@]}"
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -202,10 +220,12 @@ echo "Creating new virtual environment"
|
||||
mkdir -p "${venv}"
|
||||
"${PYTHON}" -m venv "${venv}"
|
||||
|
||||
# Extract Rhasspy tools
|
||||
rhasspy_tools_file="${download_dir}/rhasspy-tools_${FRIENDLY_ARCH}.tar.gz"
|
||||
echo "Extracting tools (${rhasspy_tools_file})"
|
||||
tar -C "${venv}" -xf "${rhasspy_tools_file}"
|
||||
if [[ -z "${no_tools}" ]]; then
|
||||
# Extract Rhasspy tools
|
||||
rhasspy_tools_file="${download_dir}/rhasspy-tools_${FRIENDLY_ARCH}.tar.gz"
|
||||
echo "Extracting tools (${rhasspy_tools_file})"
|
||||
tar -C "${venv}" -xf "${rhasspy_tools_file}"
|
||||
fi
|
||||
|
||||
# Force .venv/lib to be used
|
||||
export LD_LIBRARY_PATH="${venv}/lib:${LD_LIBRARY_PATH}"
|
||||
@@ -288,7 +308,7 @@ esac
|
||||
|
||||
if [[ -z "${no_precise}" && -z "$(command -v precise-engine)" ]]; then
|
||||
case "${CPU_ARCH}" in
|
||||
x86_64|armv7l)
|
||||
x86_64|armv7l|aarch64)
|
||||
echo "Installing Mycroft Precise"
|
||||
precise_file="${download_dir}/precise-engine_0.3.0_${CPU_ARCH}.tar.gz"
|
||||
precise_install="${venv}/lib"
|
||||
@@ -316,9 +336,11 @@ fi
|
||||
# Web Interface
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
rhasspy_web_file="${download_dir}/rhasspy-web-dist.tar.gz"
|
||||
echo "Extracting web interface (${rhasspy_web_file})"
|
||||
tar -C "${this_dir}" -xf "${rhasspy_web_file}"
|
||||
if [[ -z "${no_web}" ]]; then
|
||||
rhasspy_web_file="${download_dir}/rhasspy-web-dist.tar.gz"
|
||||
echo "Extracting web interface (${rhasspy_web_file})"
|
||||
tar -C "${this_dir}" -xf "${rhasspy_web_file}"
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$( cd "$( dirname "$0" )" && pwd )"
|
||||
this_dir="$( cd "$( dirname "$0" )" && pwd )"
|
||||
|
||||
# Try to detemine where Rhasspy is located
|
||||
if [[ -z "${RHASSPY_APP}" ]]; then
|
||||
@@ -19,6 +19,14 @@ if [[ -f "${CONFIG_PATH}" ]]; then
|
||||
RHASSPY_ARGS="--profile \"${profile_name}\" --user-profiles \"${profile_dir}\""
|
||||
fi
|
||||
|
||||
RHASSPY_VENV="${RHASSPY_APP}/.venv"
|
||||
if [[ -d "${RHASSPY_VENV}" ]]; then
|
||||
source "${RHASSPY_VENV}/bin/activate"
|
||||
|
||||
# Force .venv/lib to be used
|
||||
export LD_LIBRARY_PATH="${RHASSPY_VENV}/lib:${LD_LIBRARY_PATH}"
|
||||
fi
|
||||
|
||||
cd "${RHASSPY_APP}"
|
||||
|
||||
if [[ -z "${RHASSPY_ARGS}" ]]; then
|
||||
|
||||
+9
-1
@@ -69,7 +69,15 @@ Add to your [profile](profiles.md):
|
||||
"username": "",
|
||||
"port": 1883,
|
||||
"password": "",
|
||||
"site_id": "default"
|
||||
"site_id": "default",
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -44,7 +44,15 @@ Add to your [profile](profiles.md):
|
||||
"username": "",
|
||||
"port": 1883,
|
||||
"password": "",
|
||||
"site_id": "default"
|
||||
"site_id": "default",
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -86,7 +86,15 @@ Add to your [profile](profiles.md):
|
||||
"username": "",
|
||||
"port": 1883,
|
||||
"password": "",
|
||||
"site_id": "default"
|
||||
"site_id": "default",
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+35
-8
@@ -65,6 +65,25 @@ In order to do something with the `rhasspy_ChangeLightColor` event, create an au
|
||||
|
||||
See the documentation on [actions](https://www.home-assistant.io/docs/automation/action/) for the different things you can do with Home Assistant.
|
||||
|
||||
### Intents
|
||||
|
||||
More recent versions of Home Assistant can accept intents directly. Add the following to your `configuration.yaml` file:
|
||||
|
||||
```yaml
|
||||
intent:
|
||||
```
|
||||
|
||||
This will enable intents over the HTTP API. Next, write [intent scripts](https://www.home-assistant.io/integrations/intent_script) to handle each Rhasspy intent:
|
||||
|
||||
```yaml
|
||||
intent_script:
|
||||
ChangeLightColor:
|
||||
action:
|
||||
...
|
||||
```
|
||||
|
||||
The possible [actions](https://www.home-assistant.io/docs/automation/action/) are the same as in automations.
|
||||
|
||||
### MQTT
|
||||
|
||||
In addition to events, Rhasspy can also publish intents through MQTT ([Hermes protocol](https://docs.snips.ai/reference/dialogue#intent)).
|
||||
@@ -74,14 +93,22 @@ Add to your [profile](profiles.md):
|
||||
|
||||
```json
|
||||
"mqtt": {
|
||||
"enabled": true,
|
||||
"host": "localhost",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"port": 1883,
|
||||
"reconnect_sec": 5,
|
||||
"site_id": "default",
|
||||
"publish_intents": true
|
||||
"enabled": true,
|
||||
"host": "localhost",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"port": 1883,
|
||||
"reconnect_sec": 5,
|
||||
"site_id": "default",
|
||||
"publish_intents": true,
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+3
-2
@@ -52,8 +52,9 @@ Application authors may want to use the [rhasspy-client](https://pypi.org/projec
|
||||
* `?nohass=true` - stop Rhasspy from handling the intent
|
||||
* `?timeout=<seconds>` - override default command timeout
|
||||
* `?entity=<entity>&value=<value>` - set custom entity/value in recognized intent
|
||||
* `/api/listen-for-wake-word`
|
||||
* POST to wake Rhasspy up and return immediately
|
||||
* `/api/listen-for-wake`
|
||||
* POST "on" to have Rhasspy listen for a wake word
|
||||
* POST "off" to disable wake word
|
||||
* `/api/lookup`
|
||||
* POST word as plain text to look up or guess pronunciation
|
||||
* `?n=<number>` - return at most `n` guessed pronunciations
|
||||
|
||||
@@ -8,6 +8,7 @@ The following table summarizes language support for the various speech to text s
|
||||
| ------ | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
|
||||
| [pocketsphinx](speech-to-text.md#pocketsphinx) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ |
|
||||
| [kaldi](speech-to-text.md#kaldi) | ✓ | ✓ | | ✓ | | ✓ | | | | | ✓ | | |
|
||||
| [google](speech-to-text.md#google-cloud) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
||||
|
||||
## Pocketsphinx
|
||||
|
||||
@@ -77,6 +78,29 @@ Rhasspy expects a Kaldi-compatible profile to contain a `model` directory with a
|
||||
|
||||
If you just want to use Rhasspy for general speech to text, you can set `speech_to_text.kaldi.open_transcription` to `true` in your profile. This will use the included general language model (much slower) and ignore any custom voice commands you've specified.
|
||||
|
||||
## Google Cloud
|
||||
|
||||
Does speech recognition using [Google Cloud Speech-to-Text](https://cloud.google.com/speech-to-text) service.
|
||||
You will need an active Google Cloud subscription and a JSON private key connected to a service account enabled to use
|
||||
the speech-to-text API. The locale configured in your profile will be used for speech recognition.
|
||||
|
||||
```json
|
||||
{
|
||||
"locale": "en_US",
|
||||
"speech_to_text": {
|
||||
"system": "google",
|
||||
"google": {
|
||||
"credentials": "api-project-xxxxxxxx-abcdef.json",
|
||||
"min_confidence": 0.7
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Please note that this module sends the recorded audio after it's completed, so no streaming support.
|
||||
|
||||
See `rhasspy.stt.GoogleCloudDecoder` for details.
|
||||
|
||||
## Remote HTTP Server
|
||||
|
||||
Uses a remote HTTP server to transform speech (WAV) to text.
|
||||
|
||||
@@ -29,6 +29,19 @@ Add to your [profile](profiles.md):
|
||||
|
||||
Remove the `voice` option to have `espeak` use your profile's language automatically.
|
||||
|
||||
You may also pass additional arguments to the `espeak` command. For example,
|
||||
|
||||
```json
|
||||
"text_to_speech": {
|
||||
"system": "espeak",
|
||||
"espeak": {
|
||||
"arguments": ["-s", "80"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
will speak the sentence more slowly.
|
||||
|
||||
See `rhasspy.tts.EspeakSentenceSpeaker` for more details.
|
||||
|
||||
## Flite
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
* [RGB Light Example](#rgb-light-example)
|
||||
* [Client/Server Setup](#clientserver-setup)
|
||||
* MATRIX Labs
|
||||
* [Rhasspy Voice Assistant on MATRIX Voice and MATRIX Creator](https://www.hackster.io/matrix-labs/rhasspy-voice-assistant-on-matrix-voice-and-matrix-creator-97f92e)
|
||||
* [Adding Intents for Rhasspy Offline Voice Assistant](https://www.hackster.io/matrix-labs/adding-intents-for-rhasspy-offline-voice-assistant-faa221)
|
||||
* Rendered Obsolete
|
||||
* [Home Assistant Voice Recognition with Rhasspy](https://rendered-obsolete.github.io/2020/01/02/rhasspy.html)
|
||||
|
||||
## RGB Light Example
|
||||
|
||||
|
||||
+39
-1
@@ -142,7 +142,18 @@ More example flows are available [on Github](https://github.com/synesthesiam/rha
|
||||
|
||||
### WebSocket Events
|
||||
|
||||
Whenever a voice command is recognized, Rhasspy emits JSON events over a websocket connection available at `ws://rhasspy:12101/api/events/intent` (replace `ws://` with `wss://` if you're using [secure hosting](usage.md#secure-hosting-with-https)).
|
||||
Rhasspy supports multiple websocket event endpoints:
|
||||
|
||||
* `/api/events/intent`
|
||||
* Intent recognized or not
|
||||
* `/api/events/wake`
|
||||
* Wake word detected
|
||||
* `/api/events/text`
|
||||
* Speech transcription
|
||||
|
||||
#### WebSocket Intents
|
||||
|
||||
Whenever a voice command is recognized, Rhasspy emits JSON events over a websocket connection available at `ws://YOUR_SERVER:12101/api/events/intent` (replace `ws://` with `wss://` if you're using [secure hosting](usage.md#secure-hosting-with-https)).
|
||||
You can listen to these events in a [Node-RED](https://nodered.org) flow, and easily add offline, private voice commands to your home automation set up!
|
||||
|
||||
For the `ChangLightState` intent from the [RGB Light Example](index.md#rgb-light-example), Rhasspy will emit a JSON event like this over the websocket:
|
||||
@@ -171,6 +182,33 @@ For the `ChangLightState` intent from the [RGB Light Example](index.md#rgb-light
|
||||
}
|
||||
```
|
||||
|
||||
#### WebSocket Wake
|
||||
|
||||
When the wake word is detected, or Rhasspy is woken up via the `/api/listen-for-command` HTTP endpoint, a JSON event is emitted at `ws://YOUR_SERVER:12101/api/events/wake` (`wss://` if using HTTPS) like:
|
||||
|
||||
```json
|
||||
{
|
||||
"wakewordId": "default",
|
||||
"siteId": "default"
|
||||
}
|
||||
```
|
||||
|
||||
The `wakewordId` is set using the model or file name of your wakeword model (e.g., `porcupine` for `porcupine.ppn`). The `siteId` comes from your `mqtt.siteId` profile setting.
|
||||
|
||||
#### WebSocket Transcriptions
|
||||
|
||||
Each time a voice command is transcribed, Rhasspy emits a JSON event at `ws://YOUR_SERVER:12101/api/events/text` (`wss://` if using HTTPS) like:
|
||||
|
||||
```json
|
||||
{
|
||||
"text": "text from voice command",
|
||||
"wakewordId": "default",
|
||||
"siteId": "default"
|
||||
}
|
||||
```
|
||||
|
||||
The transcription is contained in the `text` property. `wakewordId` is the id of the wakeword that initiated the voice command (or `default`). The `siteId` comes from your `mqtt.siteId` profile setting.
|
||||
|
||||
## MQTT and Snips
|
||||
|
||||
Rhasspy is able to interoperate with Snips.AI services using the [Hermes protocol](https://docs.snips.ai/reference/hermes) over [MQTT](http://mqtt.org). The following components are Snips/Hermes compatible:
|
||||
|
||||
+9
-1
@@ -181,7 +181,15 @@ Add to your [profile](profiles.md):
|
||||
"username": "",
|
||||
"port": 1883,
|
||||
"password": "",
|
||||
"site_id": "default"
|
||||
"site_id": "default",
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ cpu_arch=$(uname --m)
|
||||
DEFINE_string 'download-dir' "${this_dir}/download" 'Directory to cache downloaded files'
|
||||
DEFINE_boolean 'precise' true 'Install Mycroft Precise'
|
||||
DEFINE_boolean 'kaldi' true 'Install Kaldi'
|
||||
DEFINE_boolean 'web' true "Install web UI"
|
||||
DEFINE_boolean 'offline' false "Don't download anything"
|
||||
DEFINE_boolean 'all-cpu' false 'Download dependencies for all CPU architectures'
|
||||
DEFINE_string 'cpu-arch' "${cpu_arch}" 'CPU architecture (x86_64, armv7l, arm64v8, armv6l)'
|
||||
@@ -44,6 +45,10 @@ if [[ "${FLAGS_kaldi}" -eq "${FLAGS_FALSE}" ]]; then
|
||||
no_kaldi='true'
|
||||
fi
|
||||
|
||||
if [[ "${FLAGS_web}" -eq "${FLAGS_FALSE}" ]]; then
|
||||
no_web='true'
|
||||
fi
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
function maybe_download {
|
||||
@@ -67,6 +72,12 @@ CPU_TO_FRIENDLY["armv7l"]="armhf"
|
||||
CPU_TO_FRIENDLY["arm64v8"]="aarch64"
|
||||
CPU_TO_FRIENDLY["armv6l"]="armv6l"
|
||||
|
||||
declare -A FRIENDLY_TO_DOCKER
|
||||
FRIENDLY_TO_DOCKER["amd64"]="amd64"
|
||||
FRIENDLY_TO_DOCKER["armhf"]="armv7"
|
||||
FRIENDLY_TO_DOCKER["aarch64"]="arm64"
|
||||
FRIENDLY_TO_DOCKER["armv6l"]="armv6"
|
||||
|
||||
# CPU architecture
|
||||
if [[ -n "${all_cpu}" ]]; then
|
||||
CPU_ARCHS=("x86_64" "armv7l" "arm64v8")
|
||||
@@ -81,12 +92,32 @@ fi
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
for FRIENDLY_ARCH in "${FRIENDLY_ARCHS[@]}"; do
|
||||
rhasspy_files=("rhasspy-tools_${FRIENDLY_ARCH}.tar.gz" "rhasspy-web-dist.tar.gz")
|
||||
rhasspy_files=()
|
||||
|
||||
if [[ -z "${no_tools}" ]]; then
|
||||
# Install Rhasspy tools
|
||||
rhasspy_files+=("rhasspy-tools_${FRIENDLY_ARCH}.tar.gz")
|
||||
fi
|
||||
|
||||
if [[ -z "${no_web}" ]]; then
|
||||
# Install web UI
|
||||
rhasspy_files+=('rhasspy-web-dist.tar.gz')
|
||||
fi
|
||||
|
||||
for rhasspy_file_name in "${rhasspy_files[@]}"; do
|
||||
rhasspy_file="${download_dir}/${rhasspy_file_name}"
|
||||
rhasspy_file_url="https://github.com/synesthesiam/rhasspy/releases/download/v2.0/${rhasspy_file_name}"
|
||||
maybe_download "${rhasspy_file_url}" "${rhasspy_file}"
|
||||
done
|
||||
|
||||
if [[ -z "${no_tools}" ]]; then
|
||||
# Create link for docker buildx
|
||||
DOCKER_ARCH="${FRIENDLY_TO_DOCKER[${FRIENDLY_ARCH}]}"
|
||||
if [[ "${FRIENDLY_ARCH}" != "${DOCKER_ARCH}" ]]; then
|
||||
ln -f "${download_dir}/rhasspy-tools_${FRIENDLY_ARCH}.tar.gz" \
|
||||
"${download_dir}/rhasspy-tools_${DOCKER_ARCH}.tar.gz"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -112,10 +143,18 @@ maybe_download "${snowboy_url}" "${snowboy_file}"
|
||||
if [[ -z "${no_precise}" ]]; then
|
||||
for CPU_ARCH in "${CPU_ARCHS[@]}"; do
|
||||
case $CPU_ARCH in
|
||||
x86_64|armv7l)
|
||||
x86_64|armv7l|aarch64)
|
||||
precise_file="${download_dir}/precise-engine_0.3.0_${CPU_ARCH}.tar.gz"
|
||||
precise_url="https://github.com/MycroftAI/mycroft-precise/releases/download/v0.3.0/precise-engine_0.3.0_${CPU_ARCH}.tar.gz"
|
||||
maybe_download "${precise_url}" "${precise_file}"
|
||||
|
||||
# Create link for docker buildx
|
||||
FRIENDLY_ARCH="${CPU_TO_FRIENDLY[${CPU_ARCH}]}"
|
||||
DOCKER_ARCH="${FRIENDLY_TO_DOCKER[${FRIENDLY_ARCH}]}"
|
||||
if [[ "${CPU_ARCH}" != "${DOCKER_ARCH}" ]]; then
|
||||
ln -f "${download_dir}/precise-engine_0.3.0_${CPU_ARCH}.tar.gz" \
|
||||
"${download_dir}/precise-engine_0.3.0_${DOCKER_ARCH}.tar.gz"
|
||||
fi
|
||||
esac
|
||||
done
|
||||
fi
|
||||
@@ -126,10 +165,19 @@ fi
|
||||
|
||||
if [[ -z "${no_kaldi}" ]]; then
|
||||
for FRIENDLY_ARCH in "${FRIENDLY_ARCHS[@]}"; do
|
||||
# Install pre-built package
|
||||
kaldi_file="${download_dir}/kaldi_${FRIENDLY_ARCH}.tar.gz"
|
||||
kaldi_url="https://github.com/synesthesiam/kaldi-docker/releases/download/v1.0/kaldi_${FRIENDLY_ARCH}.tar.gz"
|
||||
maybe_download "${kaldi_url}" "${kaldi_file}"
|
||||
if [[ "${FRIENDLY_ARCH}" != "armv6l" ]]; then
|
||||
# Install pre-built package
|
||||
kaldi_file="${download_dir}/kaldi_${FRIENDLY_ARCH}.tar.gz"
|
||||
kaldi_url="https://github.com/synesthesiam/kaldi-docker/releases/download/v1.0/kaldi_${FRIENDLY_ARCH}.tar.gz"
|
||||
maybe_download "${kaldi_url}" "${kaldi_file}"
|
||||
|
||||
# Create link for docker buildx
|
||||
DOCKER_ARCH="${FRIENDLY_TO_DOCKER[${FRIENDLY_ARCH}]}"
|
||||
if [[ "${FRIENDLY_ARCH}" != "${DOCKER_ARCH}" ]]; then
|
||||
ln -f "${download_dir}/kaldi_${FRIENDLY_ARCH}.tar.gz" \
|
||||
"${download_dir}/kaldi_${DOCKER_ARCH}.tar.gz"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
+61
-48
@@ -1,17 +1,12 @@
|
||||
#
|
||||
# Copyright 2018 Picovoice Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE"
|
||||
# file accompanying this source.
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations under the License.
|
||||
#
|
||||
|
||||
import os
|
||||
@@ -20,7 +15,7 @@ from enum import Enum
|
||||
|
||||
|
||||
class Porcupine(object):
|
||||
"""Python binding for Picovoice's wake word detection (aka Porcupine) library."""
|
||||
"""Python binding for Picovoice's wake word detection (Porcupine) engine."""
|
||||
|
||||
class PicovoiceStatuses(Enum):
|
||||
"""Status codes corresponding to 'pv_status_t' defined in 'include/picovoice.h'"""
|
||||
@@ -29,11 +24,17 @@ class Porcupine(object):
|
||||
OUT_OF_MEMORY = 1
|
||||
IO_ERROR = 2
|
||||
INVALID_ARGUMENT = 3
|
||||
STOP_ITERATION = 4
|
||||
KEY_ERROR = 5
|
||||
INVALID_STATE = 6
|
||||
|
||||
_PICOVOICE_STATUS_TO_EXCEPTION = {
|
||||
PicovoiceStatuses.OUT_OF_MEMORY: MemoryError,
|
||||
PicovoiceStatuses.IO_ERROR: IOError,
|
||||
PicovoiceStatuses.INVALID_ARGUMENT: ValueError
|
||||
PicovoiceStatuses.INVALID_ARGUMENT: ValueError,
|
||||
PicovoiceStatuses.STOP_ITERATION: StopIteration,
|
||||
PicovoiceStatuses.KEY_ERROR: KeyError,
|
||||
PicovoiceStatuses.INVALID_STATE: ValueError,
|
||||
}
|
||||
|
||||
class CPorcupine(Structure):
|
||||
@@ -48,9 +49,9 @@ class Porcupine(object):
|
||||
keyword_file_paths=None,
|
||||
sensitivities=None):
|
||||
"""
|
||||
Loads Porcupine's shared library and creates an instance of wake word detection object.
|
||||
Constructor.
|
||||
|
||||
:param library_path: Absolute path to Porcupine's shared library.
|
||||
:param library_path: Absolute path to Porcupine's dynamic library.
|
||||
:param model_file_path: Absolute path to file containing model parameters.
|
||||
:param keyword_file_path: Absolute path to keyword file containing hyper-parameters. If not present then
|
||||
'keyword_file_paths' will be used.
|
||||
@@ -64,38 +65,38 @@ class Porcupine(object):
|
||||
"""
|
||||
|
||||
if not os.path.exists(library_path):
|
||||
raise IOError(f"Could not find Porcupine's library at '{library_path}'")
|
||||
raise IOError("could'nt find Porcupine's library at '%s'" % library_path)
|
||||
|
||||
library = cdll.LoadLibrary(library_path)
|
||||
|
||||
if not os.path.exists(model_file_path):
|
||||
raise IOError(f"Could not find model file at '{model_file_path}'")
|
||||
raise IOError("could'nt find model file at '%s'" % model_file_path)
|
||||
|
||||
if sensitivity is not None and keyword_file_path is not None:
|
||||
if not os.path.exists(keyword_file_path):
|
||||
raise IOError(f"Could not find keyword file at '{keyword_file_path}'")
|
||||
raise IOError("could'nt' find keyword file at '%s'" % keyword_file_path)
|
||||
keyword_file_paths = [keyword_file_path]
|
||||
|
||||
if not (0 <= sensitivity <= 1):
|
||||
raise ValueError('Sensitivity should be within [0, 1]')
|
||||
raise ValueError('sensitivity should be within [0, 1]')
|
||||
sensitivities = [sensitivity]
|
||||
elif sensitivities is not None and keyword_file_paths is not None:
|
||||
if len(keyword_file_paths) != len(sensitivities):
|
||||
raise ValueError("Different number of sensitivity and keyword file path parameters are provided.")
|
||||
raise ValueError("different number of sensitivity and keyword file path parameters are provided.")
|
||||
|
||||
for x in keyword_file_paths:
|
||||
if not os.path.exists(os.path.expanduser(x)):
|
||||
raise IOError(f"Could not find keyword file at '{x}'")
|
||||
raise IOError("could not find keyword file at '%s'" % x)
|
||||
|
||||
for x in sensitivities:
|
||||
if not (0 <= x <= 1):
|
||||
raise ValueError('Sensitivity should be within [0, 1]')
|
||||
raise ValueError('sensitivity should be within [0, 1]')
|
||||
else:
|
||||
raise ValueError("Sensitivity and/or keyword file path is missing")
|
||||
raise ValueError("sensitivity and/or keyword file path is missing")
|
||||
|
||||
self._num_keywords = len(keyword_file_paths)
|
||||
|
||||
init_func = library.pv_porcupine_multiple_keywords_init
|
||||
init_func = library.pv_porcupine_init
|
||||
init_func.argtypes = [
|
||||
c_char_p,
|
||||
c_int,
|
||||
@@ -107,44 +108,43 @@ class Porcupine(object):
|
||||
self._handle = POINTER(self.CPorcupine)()
|
||||
|
||||
status = init_func(
|
||||
model_file_path.encode(),
|
||||
model_file_path.encode('utf-8'),
|
||||
self._num_keywords,
|
||||
(c_char_p * self._num_keywords)(*[os.path.expanduser(x).encode() for x in keyword_file_paths]),
|
||||
(c_char_p * self._num_keywords)(*[os.path.expanduser(x).encode('utf-8') for x in keyword_file_paths]),
|
||||
(c_float * self._num_keywords)(*sensitivities),
|
||||
byref(self._handle))
|
||||
if status is not self.PicovoiceStatuses.SUCCESS:
|
||||
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]('Initialization failed')
|
||||
|
||||
self.process_func = library.pv_porcupine_multiple_keywords_process
|
||||
self.process_func.argtypes = [POINTER(self.CPorcupine), POINTER(c_short), POINTER(c_int)]
|
||||
self.process_func.restype = self.PicovoiceStatuses
|
||||
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]('initialization failed')
|
||||
|
||||
self._delete_func = library.pv_porcupine_delete
|
||||
self._delete_func.argtypes = [POINTER(self.CPorcupine)]
|
||||
self._delete_func.restype = None
|
||||
|
||||
self._sample_rate = library.pv_sample_rate()
|
||||
self.process_func = library.pv_porcupine_process
|
||||
self.process_func.argtypes = [POINTER(self.CPorcupine), POINTER(c_short), POINTER(c_int)]
|
||||
self.process_func.restype = self.PicovoiceStatuses
|
||||
|
||||
version_func = library.pv_porcupine_version
|
||||
version_func.argtypes = []
|
||||
version_func.restype = c_char_p
|
||||
self._version = version_func().decode('utf-8')
|
||||
|
||||
self._frame_length = library.pv_porcupine_frame_length()
|
||||
|
||||
@property
|
||||
def sample_rate(self):
|
||||
"""Audio sample rate accepted by Porcupine library."""
|
||||
self._sample_rate = library.pv_sample_rate()
|
||||
|
||||
return self._sample_rate
|
||||
def delete(self):
|
||||
"""Releases resources acquired by Porcupine's library."""
|
||||
|
||||
@property
|
||||
def frame_length(self):
|
||||
"""Number of audio samples per frame expected by C library."""
|
||||
|
||||
return self._frame_length
|
||||
self._delete_func(self._handle)
|
||||
|
||||
def process(self, pcm):
|
||||
"""
|
||||
Monitors incoming audio stream for given wake word(s).
|
||||
Processes a frame of the incoming audio stream and emits the detection result.
|
||||
|
||||
:param pcm: An array (or array-like) of consecutive audio samples. For more information regarding required audio
|
||||
properties (i.e. sample rate, number of channels encoding, and number of samples per frame) please refer to
|
||||
'include/pv_porcupine.h'.
|
||||
:param pcm: A frame of audio samples. The number of samples per frame can be attained by calling
|
||||
'.frame_length'. The incoming audio needs to have a sample rate equal to '.sample_rate' and be 16-bit
|
||||
linearly-encoded. Porcupine operates on single-channel audio.
|
||||
:return: For a single wake-word use cse True if wake word is detected. For multiple wake-word use case it
|
||||
returns the index of detected wake-word. Indexing is 0-based and according to ordering of input keyword file
|
||||
paths. It returns -1 when no keyword is detected.
|
||||
@@ -153,7 +153,7 @@ class Porcupine(object):
|
||||
result = c_int()
|
||||
status = self.process_func(self._handle, (c_short * len(pcm))(*pcm), byref(result))
|
||||
if status is not self.PicovoiceStatuses.SUCCESS:
|
||||
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]('Processing failed')
|
||||
raise self._PICOVOICE_STATUS_TO_EXCEPTION[status]()
|
||||
|
||||
keyword_index = result.value
|
||||
|
||||
@@ -162,7 +162,20 @@ class Porcupine(object):
|
||||
else:
|
||||
return keyword_index
|
||||
|
||||
def delete(self):
|
||||
"""Releases resources acquired by Porcupine's library."""
|
||||
@property
|
||||
def version(self):
|
||||
"""Getter for version"""
|
||||
|
||||
self._delete_func(self._handle)
|
||||
return self._version
|
||||
|
||||
@property
|
||||
def frame_length(self):
|
||||
"""Getter for number of audio samples per frame."""
|
||||
|
||||
return self._frame_length
|
||||
|
||||
@property
|
||||
def sample_rate(self):
|
||||
"""Audio sample rate accepted by Picovoice."""
|
||||
|
||||
return self._sample_rate
|
||||
|
||||
+16
-8
@@ -119,7 +119,15 @@
|
||||
"publish_intents": true,
|
||||
"reconnect_sec": 5,
|
||||
"site_id": "default",
|
||||
"username": ""
|
||||
"username": "",
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
},
|
||||
"rhasspy": {
|
||||
"listen_on_start": true,
|
||||
@@ -324,31 +332,31 @@
|
||||
"cache": false
|
||||
},
|
||||
"porcupine_params.pv": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/lib/common/porcupine_params.pv",
|
||||
"url": "https://github.com/Picovoice/porcupine/raw/v1.7/lib/common/porcupine_params.pv",
|
||||
"cache": false
|
||||
},
|
||||
"porcupine.ppn": {
|
||||
"cache": false,
|
||||
"x86_64": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/resources/keyword_files/linux/porcupine_linux.ppn"
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/v1.7/resources/keyword_files/linux/porcupine_linux.ppn"
|
||||
},
|
||||
"armv7l": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/resources/keyword_files/raspberrypi/porcupine_raspberrypi.ppn"
|
||||
"url": "https://github.com/Picovoice/porcupine/raw/v1.7/resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn"
|
||||
},
|
||||
"aarch64": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/resources/keyword_files/raspberrypi/porcupine_raspberrypi.ppn"
|
||||
"url": "https://github.com/Picovoice/porcupine/raw/v1.7/resources/keyword_files/raspberry-pi/porcupine_raspberry-pi.ppn"
|
||||
}
|
||||
},
|
||||
"libpv_porcupine.so": {
|
||||
"cache": false,
|
||||
"x86_64": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/lib/linux/x86_64/libpv_porcupine.so"
|
||||
"url": "https://github.com/Picovoice/porcupine/raw/v1.7/lib/linux/x86_64/libpv_porcupine.so"
|
||||
},
|
||||
"armv7l": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/lib/raspberry-pi/cortex-a53/libpv_porcupine.so"
|
||||
"url": "https://github.com/Picovoice/porcupine/raw/v1.7/lib/raspberry-pi/cortex-a53/libpv_porcupine.so"
|
||||
},
|
||||
"aarch64": {
|
||||
"url": "https://github.com/Picovoice/Porcupine/raw/master/lib/raspberry-pi/cortex-a53/libpv_porcupine.so"
|
||||
"url": "https://github.com/Picovoice/porcupine/raw/v1.7/lib/raspberry-pi/cortex-a53/libpv_porcupine.so"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ body {
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
#logo {
|
||||
border-color: red;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.response {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
+4
-2
@@ -2,19 +2,21 @@ adapt-parser==0.3.4
|
||||
aiohttp==3.6.2
|
||||
doit==0.31.1
|
||||
fuzzywuzzy[speedup]==0.17.0
|
||||
google-cloud-speech==1.3.1
|
||||
google-cloud-texttospeech==0.5.0
|
||||
html5lib==1.0.1
|
||||
json5==0.8.5
|
||||
json5==0.7.0
|
||||
multidict==4.6.1
|
||||
networkx>=2.0
|
||||
num2words==0.5.10
|
||||
openfst==1.6.9
|
||||
paho-mqtt==1.5.0
|
||||
precise-runner==0.3.1
|
||||
PyAudio==0.2.11
|
||||
pydash==4.7.6
|
||||
quart==0.6.15
|
||||
quart-cors==0.1.3
|
||||
requests==2.22.0
|
||||
rhasspy-nlu==0.1.4.1
|
||||
rhasspy-nlu==0.1.6
|
||||
swagger-ui-py==0.1.7
|
||||
webrtcvad==2.0.10
|
||||
|
||||
+1
-1
@@ -618,7 +618,7 @@ async def wav2mqtt(core: RhasspyCore, profile: Profile, args: Any) -> None:
|
||||
|
||||
async def text2wav(core: RhasspyCore, profile: Profile, args: Any) -> None:
|
||||
"""Speak a sentence and output WAV data"""
|
||||
result = await core.speak_sentence(args)
|
||||
result = await core.speak_sentence(args.sentence)
|
||||
sys.stdout.buffer.write(result.wav_data)
|
||||
|
||||
|
||||
|
||||
+20
-6
@@ -39,6 +39,7 @@ from rhasspy.events import (
|
||||
SentenceSpoken,
|
||||
SpeakSentence,
|
||||
SpeakWord,
|
||||
StopListeningForWakeWord,
|
||||
StartRecordingToBuffer,
|
||||
StopRecordingToBuffer,
|
||||
TestMicrophones,
|
||||
@@ -88,7 +89,7 @@ class RhasspyCore:
|
||||
self._session: Optional[aiohttp.ClientSession] = aiohttp.ClientSession()
|
||||
self.dialogue_manager: Optional[RhasspyActor] = None
|
||||
|
||||
self.download_status: typing.List[str] = []
|
||||
self.download_status: List[str] = []
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@@ -98,6 +99,14 @@ class RhasspyCore:
|
||||
assert self._session is not None
|
||||
return self._session
|
||||
|
||||
@property
|
||||
def siteId(self) -> str:
|
||||
"""Get default MQTT siteId"""
|
||||
try:
|
||||
return self.profile.get("mqtt.siteId", "default").split(",")[0]
|
||||
except Exception:
|
||||
return "default"
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
async def start(
|
||||
@@ -162,10 +171,14 @@ class RhasspyCore:
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def listen_for_wake(self) -> None:
|
||||
def listen_for_wake(self, enabled: bool = True) -> None:
|
||||
"""Tell Rhasspy to start listening for a wake word."""
|
||||
assert self.actor_system is not None
|
||||
self.actor_system.tell(self.dialogue_manager, ListenForWakeWord())
|
||||
|
||||
if enabled:
|
||||
self.actor_system.tell(self.dialogue_manager, ListenForWakeWord())
|
||||
else:
|
||||
self.actor_system.tell(self.dialogue_manager, StopListeningForWakeWord())
|
||||
|
||||
async def listen_for_command(
|
||||
self,
|
||||
@@ -346,9 +359,10 @@ class RhasspyCore:
|
||||
"""Generate speech/intent artifacts for profile."""
|
||||
if no_cache:
|
||||
# Delete doit database
|
||||
db_path = Path(self.profile.write_path(".doit.db"))
|
||||
if db_path.is_file():
|
||||
db_path.unlink()
|
||||
profile_dir = Path(self.profile.write_path())
|
||||
for db_path in profile_dir.glob(".doit.db*"):
|
||||
if db_path.is_file():
|
||||
db_path.unlink()
|
||||
|
||||
assert self.actor_system is not None
|
||||
with self.actor_system.private() as sys:
|
||||
|
||||
+26
-1
@@ -386,6 +386,10 @@ class DialogueManager(RhasspyActor):
|
||||
for hook_url in awake_hooks:
|
||||
self._logger.debug("POST-ing to %s", hook_url)
|
||||
requests.post(hook_url, json=hook_json)
|
||||
|
||||
# Forward to observer
|
||||
if self.observer:
|
||||
self.send(self.observer, message)
|
||||
elif isinstance(message, WakeWordNotDetected):
|
||||
self._logger.debug("Wake word NOT detected. Staying asleep.")
|
||||
self.transition("ready")
|
||||
@@ -423,6 +427,10 @@ class DialogueManager(RhasspyActor):
|
||||
wav_data = buffer_to_wav(message.data)
|
||||
self.send(self.decoder, TranscribeWav(wav_data, handle=message.handle))
|
||||
self.transition("decoding")
|
||||
|
||||
# Forward to observer
|
||||
if self.observer:
|
||||
self.send(self.observer, message)
|
||||
else:
|
||||
self.handle_any(message, sender)
|
||||
|
||||
@@ -433,6 +441,15 @@ class DialogueManager(RhasspyActor):
|
||||
def in_decoding(self, message: Any, sender: RhasspyActor) -> None:
|
||||
"""Handle messages in decoding state."""
|
||||
if isinstance(message, WavTranscription):
|
||||
message.wakewordId = self.wake_detected_name or "default"
|
||||
|
||||
# Fix casing
|
||||
dict_casing = self.profile.get("speech_to_text.dictionary_casing", "")
|
||||
if dict_casing == "lower":
|
||||
message.text = message.text.lower()
|
||||
elif dict_casing == "upper":
|
||||
message.text = message.text.upper()
|
||||
|
||||
# text -> intent
|
||||
self._logger.debug("%s (confidence=%s)", message.text, message.confidence)
|
||||
|
||||
@@ -447,7 +464,8 @@ class DialogueManager(RhasspyActor):
|
||||
"text": message.text,
|
||||
"likelihood": 1,
|
||||
"seconds": 0,
|
||||
"wakeId": self.wake_detected_name or "",
|
||||
"wakeId": message.wakewordId,
|
||||
"wakewordId": message.wakewordId,
|
||||
}
|
||||
).encode()
|
||||
|
||||
@@ -460,6 +478,10 @@ class DialogueManager(RhasspyActor):
|
||||
)
|
||||
self.send(self.mqtt, MqttPublish("hermes/asr/textCaptured", payload))
|
||||
|
||||
# Forward to observer
|
||||
if self.observer:
|
||||
self.send(self.observer, message)
|
||||
|
||||
# Pass to intent recognizer
|
||||
self.send(
|
||||
self.recognizer,
|
||||
@@ -732,6 +754,9 @@ class DialogueManager(RhasspyActor):
|
||||
elif isinstance(message, GetProblems):
|
||||
# Report problems from child actors
|
||||
self.send(sender, Problems(self.problems))
|
||||
elif isinstance(message, (ListenForWakeWord, StopListeningForWakeWord)):
|
||||
# Forward to wake actor
|
||||
self.send(self.wake, message)
|
||||
else:
|
||||
self.handle_forward(message, sender)
|
||||
|
||||
|
||||
+8
-1
@@ -390,10 +390,17 @@ class TranscribeWav:
|
||||
class WavTranscription:
|
||||
"""Response to TranscribeWav."""
|
||||
|
||||
def __init__(self, text: str, handle: bool = True, confidence: float = 1) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
text: str,
|
||||
handle: bool = True,
|
||||
confidence: float = 1,
|
||||
wakewordId: str = "default",
|
||||
) -> None:
|
||||
self.text = text
|
||||
self.confidence = confidence
|
||||
self.handle = handle
|
||||
self.wakewordId = wakewordId
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -389,6 +389,7 @@ class RasaIntentRecognizer(RhasspyActor):
|
||||
RhasspyActor.__init__(self)
|
||||
self.project_name = ""
|
||||
self.parse_url = ""
|
||||
self.min_confidence: float = 0
|
||||
|
||||
def to_started(self, from_state: str) -> None:
|
||||
"""Transition to started state."""
|
||||
@@ -397,6 +398,7 @@ class RasaIntentRecognizer(RhasspyActor):
|
||||
self.project_name = rasa_config.get(
|
||||
"project_name", f"rhasspy_{self.profile.name}"
|
||||
)
|
||||
self.min_confidence = rasa_config.get("min_confidence", 0)
|
||||
self.parse_url = urljoin(url, "model/parse")
|
||||
|
||||
def in_started(self, message: Any, sender: RhasspyActor) -> None:
|
||||
@@ -406,6 +408,15 @@ class RasaIntentRecognizer(RhasspyActor):
|
||||
intent = self.recognize(message.text)
|
||||
intent["intent"]["name"] = intent["intent"]["name"] or ""
|
||||
logging.debug(repr(intent))
|
||||
confidence = intent["intent"]["confidence"]
|
||||
if confidence < self.min_confidence:
|
||||
intent["intent"]["name"] = ""
|
||||
|
||||
self._logger.warning(
|
||||
"Intent did not meet confidence threshold: %s < %s",
|
||||
confidence,
|
||||
self.min_confidence,
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception("in_started")
|
||||
intent = empty_intent()
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
"""Training for intent recognizers."""
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
from collections import Counter, defaultdict
|
||||
from io import StringIO
|
||||
from typing import Any, Callable, Dict, List, Set, Type
|
||||
@@ -14,7 +10,7 @@ from urllib.parse import urljoin
|
||||
|
||||
from rhasspy.actor import RhasspyActor
|
||||
from rhasspy.events import IntentTrainingComplete, IntentTrainingFailed, TrainIntent
|
||||
from rhasspy.utils import lcm, make_sentences_by_intent, load_converters
|
||||
from rhasspy.utils import make_sentences_by_intent, load_converters
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
@@ -197,7 +193,8 @@ class RasaIntentTrainer(RhasspyActor):
|
||||
entity = None
|
||||
sentence_tokens = []
|
||||
entity_tokens = []
|
||||
for token in intent_sent["raw_tokens"]:
|
||||
for raw_token in intent_sent["raw_tokens"]:
|
||||
token = raw_token
|
||||
if entity and (raw_index >= entity["raw_end"]):
|
||||
# Finish current entity
|
||||
last_token = entity_tokens[-1]
|
||||
@@ -221,7 +218,7 @@ class RasaIntentTrainer(RhasspyActor):
|
||||
# Add directly to sentence
|
||||
sentence_tokens.append(token)
|
||||
|
||||
raw_index += len(token) + 1
|
||||
raw_index += len(raw_token) + 1
|
||||
|
||||
if entity:
|
||||
# Finish final entity
|
||||
|
||||
+33
-4
@@ -10,8 +10,13 @@ from typing import Any, Dict, List
|
||||
import pydash
|
||||
|
||||
from rhasspy.actor import RhasspyActor
|
||||
from rhasspy.events import (MqttConnected, MqttDisconnected, MqttMessage,
|
||||
MqttPublish, MqttSubscribe)
|
||||
from rhasspy.events import (
|
||||
MqttConnected,
|
||||
MqttDisconnected,
|
||||
MqttMessage,
|
||||
MqttPublish,
|
||||
MqttSubscribe,
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Events
|
||||
@@ -48,6 +53,7 @@ class HermesMqtt(RhasspyActor):
|
||||
self.password = None
|
||||
self.reconnect_sec = 5
|
||||
self.publish_intents = True
|
||||
self.tls = {"enabled": False}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
@@ -66,6 +72,7 @@ class HermesMqtt(RhasspyActor):
|
||||
self.password = self.profile.get("mqtt.password", None)
|
||||
self.reconnect_sec = self.profile.get("mqtt.reconnect_sec", 5)
|
||||
self.publish_intents = self.profile.get("mqtt.publish_intents", True)
|
||||
self.tls = self.profile.get("mqtt.tls", {"enabled": False})
|
||||
|
||||
if self.profile.get("mqtt.enabled", False):
|
||||
self.transition("connecting")
|
||||
@@ -84,6 +91,28 @@ class HermesMqtt(RhasspyActor):
|
||||
self.client.on_message = self.on_message
|
||||
self.client.on_disconnect = self.on_disconnect
|
||||
|
||||
if pydash.get(self.tls, "enabled", False):
|
||||
import ssl
|
||||
|
||||
allowed_cert_reqs = {
|
||||
"CERT_REQUIRED": ssl.CERT_REQUIRED,
|
||||
"CERT_OPTIONAL": ssl.CERT_OPTIONAL,
|
||||
"CERT_NONE": ssl.CERT_NONE,
|
||||
}
|
||||
|
||||
self.client.tls_set(
|
||||
ca_certs=pydash.get(self.tls, "ca_certs", None),
|
||||
cert_reqs=pydash.get(
|
||||
allowed_cert_reqs,
|
||||
pydash.get(self.tls, "cert_reqs", "CERT_REQUIRED"),
|
||||
ssl.CERT_REQUIRED,
|
||||
),
|
||||
certfile=pydash.get(self.tls, "certfile", None),
|
||||
ciphers=pydash.get(self.tls, "ciphers", None),
|
||||
keyfile=pydash.get(self.tls, "keyfile", None),
|
||||
tls_version=ssl.PROTOCOL_TLS,
|
||||
)
|
||||
|
||||
if self.username:
|
||||
self._logger.debug("Logging in as %s", self.username)
|
||||
self.client.username_pw_set(self.username, self.password)
|
||||
@@ -259,12 +288,12 @@ class HermesMqtt(RhasspyActor):
|
||||
"slotName": ev["entity"],
|
||||
"confidence": 1,
|
||||
"value": {"kind": ev["entity"], "value": ev["value"]},
|
||||
"rawValue": ev["value"],
|
||||
"rawValue": ev.get("raw_value", ev["value"]),
|
||||
}
|
||||
for ev in intent.get("entities", [])
|
||||
],
|
||||
"asrTokens": [],
|
||||
"asrConfidence": 1
|
||||
"asrConfidence": 1,
|
||||
}
|
||||
).encode()
|
||||
|
||||
|
||||
@@ -417,7 +417,18 @@
|
||||
"reconnect_sec": { "type": "integer", "min": 0 },
|
||||
"site_id": { "type": "string" },
|
||||
"username": { "type": "string" },
|
||||
"publish_intents": { "type": "boolean" }
|
||||
"publish_intents": { "type": "boolean" },
|
||||
"tls": {
|
||||
"type": "dict",
|
||||
"schema": {
|
||||
"enabled": { "type": "boolean" },
|
||||
"ca_certs": { "type": "string" },
|
||||
"cert_reqs": { "type": "string" },
|
||||
"certfile": { "type": "string" },
|
||||
"ciphers": { "type": "string" },
|
||||
"keyfile": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
+91
-1
@@ -25,6 +25,7 @@ def get_decoder_class(system: str) -> Type[RhasspyActor]:
|
||||
"pocketsphinx",
|
||||
"kaldi",
|
||||
"remote",
|
||||
"google",
|
||||
"hass_stt",
|
||||
"command",
|
||||
], f"Invalid speech to text system: {system}"
|
||||
@@ -38,6 +39,9 @@ def get_decoder_class(system: str) -> Type[RhasspyActor]:
|
||||
if system == "remote":
|
||||
# Use remote Rhasspy server
|
||||
return RemoteDecoder
|
||||
if system == "google":
|
||||
# Use remote Google Cloud
|
||||
return GoogleCloudDecoder
|
||||
if system == "hass_stt":
|
||||
# Use Home Assistant STT platform
|
||||
return HomeAssistantSTTIntegration
|
||||
@@ -320,6 +324,90 @@ class RemoteDecoder(RhasspyActor):
|
||||
return response.text
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Google Cloud Speech-to-text decoder
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class GoogleCloudDecoder(RhasspyActor):
|
||||
"""Forwards speech to text request to Google Cloud STT service"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
RhasspyActor.__init__(self)
|
||||
self.client = None
|
||||
self.language_code = None
|
||||
self.min_confidence: float = 0
|
||||
|
||||
def to_started(self, from_state: str) -> None:
|
||||
"""Transition to started state."""
|
||||
from google.cloud import speech
|
||||
|
||||
credentials_file = self.profile.get("speech_to_text.google.credentials")
|
||||
self.min_confidence = self.profile.get("speech_to_text.google.min_confidence")
|
||||
self.language_code = self.profile.get("locale").replace("_", "-")
|
||||
from google.auth import environment_vars
|
||||
|
||||
os.environ[environment_vars.CREDENTIALS] = credentials_file
|
||||
self.client = speech.SpeechClient()
|
||||
|
||||
def in_started(self, message: Any, sender: RhasspyActor) -> None:
|
||||
"""Handle messages in started state."""
|
||||
if isinstance(message, TranscribeWav):
|
||||
try:
|
||||
text, confidence = self.transcribe_wav(message.wav_data)
|
||||
self._logger.debug(text)
|
||||
self.send(
|
||||
message.receiver or sender,
|
||||
WavTranscription(
|
||||
text, confidence=confidence, handle=message.handle
|
||||
),
|
||||
)
|
||||
except Exception:
|
||||
self._logger.exception("transcribing wav")
|
||||
|
||||
# Send empty transcription back
|
||||
self.send(
|
||||
message.receiver or sender,
|
||||
WavTranscription("", confidence=0, handle=message.handle),
|
||||
)
|
||||
|
||||
def transcribe_wav(self, wav_data: bytes) -> Tuple[str, float]:
|
||||
"""POST to remote server and return response."""
|
||||
from google.cloud.speech import enums
|
||||
from google.cloud.speech import types
|
||||
|
||||
self._logger.debug(
|
||||
"POSTing %d byte(s) of WAV data to Google Cloud STT", len(wav_data)
|
||||
)
|
||||
|
||||
audio = types.RecognitionAudio(content=wav_data)
|
||||
config = types.RecognitionConfig(
|
||||
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
|
||||
sample_rate_hertz=16000,
|
||||
model="command_and_search",
|
||||
language_code=self.language_code,
|
||||
)
|
||||
|
||||
response = self.client.recognize(config, audio)
|
||||
if len(response.results) == 0:
|
||||
self._logger.debug("No results returned.")
|
||||
return "", 0
|
||||
|
||||
result = response.results[0].alternatives[0]
|
||||
|
||||
self._logger.debug("Transcription confidence: %s", result.confidence)
|
||||
if result.confidence >= self.min_confidence:
|
||||
return result.transcript, result.confidence
|
||||
|
||||
self._logger.warning(
|
||||
"Transcription did not meet confidence threshold: %s < %s",
|
||||
result.confidence,
|
||||
self.min_confidence,
|
||||
)
|
||||
|
||||
return "", 0
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Kaldi Decoder
|
||||
# http://kaldi-asr.org
|
||||
@@ -565,7 +653,9 @@ class HomeAssistantSTTIntegration(RhasspyActor):
|
||||
audio_data = audio_data[self.chunk_size :]
|
||||
|
||||
# POST WAV data to STT
|
||||
response = requests.post(stt_url, data=generate_chunks(), **kwargs) # type: ignore
|
||||
response = requests.post(
|
||||
stt_url, data=generate_chunks(), **kwargs
|
||||
) # type: ignore
|
||||
response.raise_for_status()
|
||||
|
||||
response_json = response.json()
|
||||
|
||||
@@ -257,7 +257,7 @@ def train_profile(profile_dir: Path, profile: Profile) -> Tuple[int, List[str]]:
|
||||
n = int(match.group(1))
|
||||
|
||||
# 75 -> (seventy five):75!int
|
||||
number_text = num2words(n, lang=language).replace("-", " ").strip()
|
||||
number_text = re.sub(r"[-,]\s*", " ", num2words(n, lang=language)).strip()
|
||||
assert number_text, f"Empty num2words result for {n}"
|
||||
number_words = number_text.split()
|
||||
|
||||
@@ -526,6 +526,13 @@ def train_profile(profile_dir: Path, profile: Profile) -> Tuple[int, List[str]]:
|
||||
for word in read_dict(dict_file):
|
||||
print(word, file=vocab_file)
|
||||
|
||||
if profile.get("wake.system", "dummy") == "pocketsphinx":
|
||||
# Add words from Pocketsphinx wake keyphrase
|
||||
keyphrase = profile.get("wake.pocketsphinx.keyphrase", "")
|
||||
if keyphrase:
|
||||
for word in re.split(r"\s+", keyphrase):
|
||||
print(word, file=vocab_file)
|
||||
|
||||
@create_after(executed="language_model")
|
||||
def task_vocab():
|
||||
"""Writes all vocabulary words to a file from intent.fst."""
|
||||
|
||||
+3
-1
@@ -94,6 +94,7 @@ class EspeakSentenceSpeaker(RhasspyActor):
|
||||
self.disable_wake = True
|
||||
self.enable_wake = False
|
||||
self.wake: Optional[RhasspyActor] = None
|
||||
self.espeak_args: List[str] = []
|
||||
|
||||
def to_started(self, from_state: str) -> None:
|
||||
"""Transition to started state."""
|
||||
@@ -104,6 +105,7 @@ class EspeakSentenceSpeaker(RhasspyActor):
|
||||
self.wake = self.config.get("wake")
|
||||
self.wake_on_start = self.profile.get("rhasspy.listen_on_start", False)
|
||||
self.disable_wake = self.profile.get("text_to_speech.disable_wake", True)
|
||||
self.espeak_args = list(self.profile.get("text_to_speech.espeak.arguments", []))
|
||||
self.transition("ready")
|
||||
|
||||
def in_ready(self, message: Any, sender: RhasspyActor) -> None:
|
||||
@@ -143,7 +145,7 @@ class EspeakSentenceSpeaker(RhasspyActor):
|
||||
def speak(self, sentence: str, voice: Optional[str] = None) -> bytes:
|
||||
"""Get WAV buffer for sentence."""
|
||||
try:
|
||||
espeak_cmd = ["espeak"]
|
||||
espeak_cmd = ["espeak"] + self.espeak_args
|
||||
if voice:
|
||||
espeak_cmd.extend(["-v", str(voice)])
|
||||
|
||||
|
||||
+1
-1
@@ -407,7 +407,7 @@ def numbers_to_words(sentence: str, language: Optional[str] = None) -> str:
|
||||
number = float(word)
|
||||
|
||||
# 75 -> seventy-five -> seventy five
|
||||
words[i] = num2words(number, lang=language).replace("-", " ")
|
||||
words[i] = re.sub(r"[-,]\s*", " ", num2words(number, lang=language))
|
||||
changed = True
|
||||
except ValueError:
|
||||
pass # not a number
|
||||
|
||||
+12
-8
@@ -227,18 +227,19 @@ class PocketsphinxWakeListener(RhasspyActor):
|
||||
self.keyphrase = self.profile.get("wake.pocketsphinx.keyphrase", "")
|
||||
assert self.keyphrase, "No wake keyphrase"
|
||||
|
||||
# Fix casing
|
||||
dict_casing = self.profile.get("speech_to_text.dictionary_casing", "")
|
||||
if dict_casing == "lower":
|
||||
self.keyphrase = self.keyphrase.lower()
|
||||
elif dict_casing == "upper":
|
||||
self.keyphrase = self.keyphrase.upper()
|
||||
|
||||
# Verify that keyphrase words are in dictionary
|
||||
keyphrase_words = re.split(r"\s+", self.keyphrase)
|
||||
with open(dict_path, "r") as dict_file:
|
||||
word_dict = read_dict(dict_file)
|
||||
|
||||
dict_upper = self.profile.get("speech_to_text.dictionary_upper", False)
|
||||
for word in keyphrase_words:
|
||||
if dict_upper:
|
||||
word = word.upper()
|
||||
else:
|
||||
word = word.lower()
|
||||
|
||||
if word not in word_dict:
|
||||
self._logger.warning("%s not in dictionary", word)
|
||||
|
||||
@@ -570,7 +571,9 @@ class PreciseWakeListener(RhasspyActor):
|
||||
self.prediction_sem = threading.Semaphore()
|
||||
for _ in range(num_chunks):
|
||||
chunk = self.audio_buffer[: self.chunk_size]
|
||||
self.stream.write(chunk)
|
||||
if chunk:
|
||||
self.stream.write(chunk)
|
||||
|
||||
self.audio_buffer = self.audio_buffer[self.chunk_size :]
|
||||
|
||||
if self.send_not_detected:
|
||||
@@ -922,7 +925,8 @@ class PorcupineWakeListener(RhasspyActor):
|
||||
"""Load porcupine library."""
|
||||
if self.handle is None:
|
||||
for kw_path in self.keyword_paths:
|
||||
assert kw_path.is_file(), f"Missing {kw_path}"
|
||||
if not kw_path.is_file():
|
||||
self._logger.error("Missing porcupine keyword at {kw_path}")
|
||||
|
||||
from porcupine import Porcupine
|
||||
|
||||
|
||||
+28
-4
@@ -3,7 +3,7 @@
|
||||
<!-- Top Bar -->
|
||||
<nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top">
|
||||
<a href="/">
|
||||
<img class="navbar-brand" v-bind:class="spinnerClass" src="/img/logo.png">
|
||||
<img id="logo" class="navbar-brand" v-bind:class="spinnerClass" src="/img/logo.png">
|
||||
</a>
|
||||
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
@@ -191,7 +191,9 @@
|
||||
|
||||
version: '',
|
||||
|
||||
downloadStatus: ''
|
||||
downloadStatus: '',
|
||||
|
||||
wakeSocket: null
|
||||
}
|
||||
},
|
||||
|
||||
@@ -215,8 +217,8 @@
|
||||
this.alertText = text
|
||||
this.alertClass = 'alert-' + level
|
||||
|
||||
// Hide alert after 10 seconds
|
||||
setTimeout(this.clearAlert, 10000)
|
||||
// Hide alert after 20 seconds
|
||||
setTimeout(this.clearAlert, 20000)
|
||||
},
|
||||
|
||||
beginAsync: function() {
|
||||
@@ -365,6 +367,27 @@
|
||||
if (this.downloading) {
|
||||
setTimeout(this.updateDownloadStatus, 1000)
|
||||
}
|
||||
},
|
||||
|
||||
connectWakeSocket: function() {
|
||||
// Connect to /api/events/intent websocket
|
||||
var wsProtocol = 'ws://'
|
||||
if (window.location.protocol == 'https:') {
|
||||
wsProtocol = 'wss://'
|
||||
}
|
||||
|
||||
var wsURL = wsProtocol + window.location.host + '/api/events/wake'
|
||||
this.wakeSocket = new WebSocket(wsURL)
|
||||
this.wakeSocket.onmessage = (evt) => {
|
||||
$('#logo').css('filter', 'invert()')
|
||||
setTimeout(() => {
|
||||
$('#logo').css('filter', 'initial')
|
||||
}, 2000)
|
||||
}
|
||||
this.wakeSocket.onclose = () => {
|
||||
// Try to reconnect
|
||||
setTimeout(this.connectWakeSocket, 1000)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -376,6 +399,7 @@
|
||||
this.getCustomWords()
|
||||
this.getUnknownWords()
|
||||
this.getProblems()
|
||||
this.connectWakeSocket()
|
||||
this.$options.sockets.onmessage = function(event) {
|
||||
this.rhasspyLog = event.data + '\n' + this.rhasspyLog
|
||||
}
|
||||
|
||||
@@ -109,7 +109,15 @@ const profileDefaults = {
|
||||
"reconnect_sec": 5,
|
||||
"site_id": "default",
|
||||
"username": "",
|
||||
"publish_intents": true
|
||||
"publish_intents": true,
|
||||
"tls": {
|
||||
"enabled": false,
|
||||
"ca_certs": "",
|
||||
"cert_reqs": "CERT_REQUIRED",
|
||||
"certfile": "",
|
||||
"ciphers": "",
|
||||
"keyfile": ""
|
||||
}
|
||||
},
|
||||
"rhasspy": {
|
||||
"default_profile": "en",
|
||||
|
||||
@@ -136,7 +136,9 @@
|
||||
audioContext: null,
|
||||
recorder: null,
|
||||
|
||||
sendHass: true
|
||||
sendHass: true,
|
||||
|
||||
intentSocket: null
|
||||
}
|
||||
},
|
||||
|
||||
@@ -276,7 +278,30 @@
|
||||
playLastVoiceCommand: function(event) {
|
||||
TranscribeService.playRecording()
|
||||
.catch(err => this.$parent.error(err))
|
||||
},
|
||||
|
||||
connectIntentSocket: function() {
|
||||
// Connect to /api/events/intent websocket
|
||||
var wsProtocol = 'ws://'
|
||||
if (window.location.protocol == 'https:') {
|
||||
wsProtocol = 'wss://'
|
||||
}
|
||||
|
||||
var wsURL = wsProtocol + window.location.host + '/api/events/intent'
|
||||
this.intentSocket = new WebSocket(wsURL)
|
||||
this.intentSocket.onmessage = (evt) => {
|
||||
this.jsonSource = JSON.parse(evt.data)
|
||||
this.sentence = this.jsonSource.raw_text
|
||||
}
|
||||
this.intentSocket.onclose = () => {
|
||||
// Try to reconnect
|
||||
setTimeout(this.connectIntentSocket, 1000)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted: function() {
|
||||
this.connectIntentSocket()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<p class="text-muted">
|
||||
Requires the <a href="https://www.home-assistant.io/integrations/intent/">intent component</a> in your <tt>configuration.yaml</tt>
|
||||
Requires the <tt>intent</tt> component and <a href="https://www.home-assistant.io/integrations/intent_script">intent scripts</a> in your <tt>configuration.yaml</tt>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -137,7 +137,7 @@
|
||||
<div class="form-row">
|
||||
<label for="remote-handle-url" class="col-form-label">Remote URL</label>
|
||||
<div class="col">
|
||||
<input id="remote-handle-url" type="text" class="form-control" v-model="profile.handle.remote.url" :disabled="profile.intent.system != 'remote'">
|
||||
<input id="remote-handle-url" type="text" class="form-control" v-model="profile.handle.remote.url" :disabled="profile.handle.system != 'remote'">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -70,6 +70,58 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<input id="mqtt-tls-enabled" type="checkbox" v-model="profile.mqtt.tls.enabled" :disabled="!profile.mqtt.enabled">
|
||||
<label for="mqtt-tls-enabled" class="col-form-label">Enable MQTT over TLS</label>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="profile.mqtt.tls.enabled">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="mqtt-tls-ca_certs" class="col-form-label">ca_certs</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="mqtt-tls-ca_certs" type="text" class="form-control" v-model="profile.mqtt.tls.ca_certs" :disabled="!profile.mqtt.enabled">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="mqtt-tls-cert_reqs" class="col-form-label">cert_reqs</label>
|
||||
<div class="col-sm-auto">
|
||||
<select id="mqtt-tls-cert_reqs" v-model="profile.mqtt.tls.cert_reqs" :disabled="!profile.mqtt.enabled">
|
||||
<option value="CERT_REQUIRED" default>CERT_REQUIRED</option>
|
||||
<option value="CERT_OPTIONAL">CERT_OPTIONAL</option>
|
||||
<option value="CERT_NONE">CERT_NONE</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="mqtt-tls-certfile" class="col-form-label">certfile</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="mqtt-tls-certfile" type="text" class="form-control" v-model="profile.mqtt.tls.certfile" :disabled="!profile.mqtt.enabled">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="mqtt-tls-ciphers" class="col-form-label">ciphers</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="mqtt-tls-ciphers" type="text" class="form-control" v-model="profile.mqtt.tls.ciphers" :disabled="!profile.mqtt.enabled">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="mqtt-tls-keyfile" class="col-form-label">keyfile</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="mqtt-tls-keyfile" type="text" class="form-control" v-model="profile.mqtt.tls.keyfile" :disabled="!profile.mqtt.enabled">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<input type="checkbox" id="mqtt-publish_intents" v-model="profile.mqtt.publish_intents" :disabled="!profile.mqtt.enabled">
|
||||
|
||||
@@ -89,28 +89,44 @@
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<!-- <div class="form-group"> -->
|
||||
<!-- <div class="form-row"> -->
|
||||
<!-- <div class="form-check"> -->
|
||||
<!-- <input class="form-check-input" type="radio" name="wake-system" id="wake-system-precise" value="precise" v-model="profile.wake.system"> -->
|
||||
<!-- <label class="form-check-label" for="wake-system-precise"> -->
|
||||
<!-- Use <a href="https://github.com/MycroftAI/mycroft-precise">Mycroft Precise</a> on this device -->
|
||||
<!-- </label> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="form-group"> -->
|
||||
<!-- <div class="form-row"> -->
|
||||
<!-- <label for="precise-model" class="col-form-label">Model Name</label> -->
|
||||
<!-- <div class="col-sm-auto"> -->
|
||||
<!-- <input id="precise-model" type="text" class="form-control" v-model="profile.wake.precise.model" :disabled="profile.wake.system != 'precise'"> -->
|
||||
<!-- </div> -->
|
||||
<!-- <div class="col text-muted"> -->
|
||||
<!-- Put models in your profile directory -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
<!-- <hr> -->
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="wake-system" id="wake-system-precise" value="precise" v-model="profile.wake.system">
|
||||
<label class="form-check-label" for="wake-system-precise">
|
||||
Use <a href="https://github.com/MycroftAI/mycroft-precise">Mycroft Precise</a> on this device
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="precise-model" class="col-form-label">Model Name</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="precise-model" type="text" class="form-control" v-model="profile.wake.precise.model" :disabled="profile.wake.system != 'precise'">
|
||||
</div>
|
||||
<div class="col text-muted">
|
||||
Put models in the <tt>precise</tt> directory in your profile
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="wake-precise-sensitivity" class="col-form-label">Sensitivity</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="wake-precise-sensitivity" type="text" class="form-control" v-model="profile.wake.precise.sensitivity" :disabled="profile.wake.system != 'precise'">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<label for="wake-precise-trigger-level" class="col-form-label">Trigger Level</label>
|
||||
<div class="col-sm-auto">
|
||||
<input id="wake-precise-trigger-level" type="text" class="form-control" v-model="profile.wake.precise.trigger_level" :disabled="profile.wake.system != 'precise'">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-check">
|
||||
|
||||
Reference in New Issue
Block a user