Code cleanup

This commit is contained in:
Michael Hansen
2019-12-27 21:19:46 -05:00
parent 13f183afd4
commit a627f8746c
18 changed files with 71 additions and 183 deletions
+6 -21
View File
@@ -12,32 +12,17 @@ from typing import Any, Dict, List, Tuple, Union
from uuid import uuid4
import attr
from quart import (
Quart,
Response,
jsonify,
request,
safe_join,
send_file,
send_from_directory,
websocket,
)
from quart import (Quart, Response, jsonify, request, safe_join, send_file,
send_from_directory, websocket)
from quart_cors import cors
from swagger_ui import quart_api_doc
from rhasspy.actor import ActorSystem, ConfigureEvent, RhasspyActor
from rhasspy.core import RhasspyCore
from rhasspy.events import ProfileTrainingFailed, IntentRecognized
from rhasspy.utils import (
FunctionLoggingHandler,
buffer_to_wav,
get_all_intents,
get_ini_paths,
get_wav_duration,
load_phoneme_examples,
read_dict,
recursive_remove,
)
from rhasspy.events import IntentRecognized, ProfileTrainingFailed
from rhasspy.utils import (FunctionLoggingHandler, buffer_to_wav,
get_all_intents, get_ini_paths, get_wav_duration,
load_phoneme_examples, read_dict, recursive_remove)
# -----------------------------------------------------------------------------
# Quart Web App Setup
-1
View File
@@ -4,7 +4,6 @@ import asyncio
import io
import json
import logging
# Configure logging
import logging.config
import os
+1 -1
View File
@@ -6,7 +6,7 @@ import uuid
from typing import Any, Dict, List, Optional, Type
from rhasspy.actor import RhasspyActor
from rhasspy.events import PlayWavFile, PlayWavData, WavPlayed, MqttPublish
from rhasspy.events import MqttPublish, PlayWavData, PlayWavFile, WavPlayed
# -----------------------------------------------------------------------------
+4 -11
View File
@@ -14,17 +14,10 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Any, Dict, List, Optional, Type
from rhasspy.actor import RhasspyActor
from rhasspy.events import (
AudioData,
IntentRecognized,
MqttMessage,
MqttSubscribe,
WavTranscription,
StartRecordingToBuffer,
StopRecordingToBuffer,
StartStreaming,
StopStreaming,
)
from rhasspy.events import (AudioData, IntentRecognized, MqttMessage,
MqttSubscribe, StartRecordingToBuffer,
StartStreaming, StopRecordingToBuffer,
StopStreaming, WavTranscription)
from rhasspy.utils import convert_wav
# -----------------------------------------------------------------------------
+3 -9
View File
@@ -11,15 +11,9 @@ from typing import Any, Dict, List, Optional, Type
import webrtcvad
from rhasspy.actor import RhasspyActor, WakeupMessage
from rhasspy.events import (
AudioData,
StartStreaming,
StopStreaming,
MqttMessage,
MqttSubscribe,
ListenForCommand,
VoiceCommand,
)
from rhasspy.events import (AudioData, ListenForCommand, MqttMessage,
MqttSubscribe, StartStreaming, StopStreaming,
VoiceCommand)
from rhasspy.utils import convert_wav
# -----------------------------------------------------------------------------
+14 -37
View File
@@ -14,44 +14,21 @@ import aiohttp
# Internal imports
from rhasspy.actor import ActorSystem, ConfigureEvent, RhasspyActor
from rhasspy.events import (
AudioData,
StartRecordingToBuffer,
StopRecordingToBuffer,
GetActorStates,
GetMicrophones,
GetProblems,
GetSpeakers,
GetVoiceCommand,
GetWordPhonemes,
GetWordPronunciations,
HandleIntent,
ListenForCommand,
ListenForWakeWord,
MqttPublish,
PlayWavData,
PlayWavFile,
Problems,
ProfileTrainingComplete,
ProfileTrainingFailed,
RecognizeIntent,
SpeakSentence,
SpeakWord,
TestMicrophones,
TrainProfile,
TranscribeWav,
VoiceCommand,
WakeWordDetected,
WakeWordNotDetected,
IntentRecognized,
IntentHandled,
WordPhonemes,
WordPronunciations,
WordSpoken,
WavTranscription,
SentenceSpoken,
)
from rhasspy.dialogue import DialogueManager
from rhasspy.events import (AudioData, GetActorStates, GetMicrophones,
GetProblems, GetSpeakers, GetVoiceCommand,
GetWordPhonemes, GetWordPronunciations,
HandleIntent, IntentHandled, IntentRecognized,
ListenForCommand, ListenForWakeWord, MqttPublish,
PlayWavData, PlayWavFile, Problems,
ProfileTrainingComplete, ProfileTrainingFailed,
RecognizeIntent, SentenceSpoken, SpeakSentence,
SpeakWord, StartRecordingToBuffer,
StopRecordingToBuffer, TestMicrophones,
TrainProfile, TranscribeWav, VoiceCommand,
WakeWordDetected, WakeWordNotDetected,
WavTranscription, WordPhonemes, WordPronunciations,
WordSpoken)
from rhasspy.profiles import Profile
from rhasspy.utils import numbers_to_words
+18 -50
View File
@@ -9,58 +9,26 @@ from typing import Any, Dict, List, Optional, Type
import pydash
import pywrapfst as fst
from rhasspy.actor import (
ActorExitRequest,
ChildActorExited,
Configured,
ConfigureEvent,
RhasspyActor,
StateTransition,
WakeupMessage,
)
from rhasspy.actor import (ActorExitRequest, ChildActorExited, Configured,
ConfigureEvent, RhasspyActor, StateTransition,
WakeupMessage)
from rhasspy.audio_player import get_sound_class
from rhasspy.events import (
PlayWavData,
PlayWavFile,
WavPlayed,
AudioData,
StartRecordingToBuffer,
StopRecordingToBuffer,
ListenForCommand,
VoiceCommand,
IntentRecognized,
RecognizeIntent,
HandleIntent,
IntentHandled,
IntentTrainingComplete,
IntentTrainingFailed,
TrainIntent,
MqttPublish,
GetWordPhonemes,
GetWordPronunciations,
SpeakWord,
TranscribeWav,
WavTranscription,
SpeakSentence,
ListenForWakeWord,
StopListeningForWakeWord,
WakeWordDetected,
WakeWordNotDetected,
Ready,
GetMicrophones,
TestMicrophones,
GetSpeakers,
TrainProfile,
ProfileTrainingFailed,
ProfileTrainingComplete,
GetVoiceCommand,
GetActorStates,
GetProblems,
Problems,
)
from rhasspy.audio_recorder import get_microphone_class, HTTPAudioRecorder
from rhasspy.audio_recorder import HTTPAudioRecorder, get_microphone_class
from rhasspy.command_listener import get_command_class
from rhasspy.events import (AudioData, GetActorStates, GetMicrophones,
GetProblems, GetSpeakers, GetVoiceCommand,
GetWordPhonemes, GetWordPronunciations,
HandleIntent, IntentHandled, IntentRecognized,
IntentTrainingComplete, IntentTrainingFailed,
ListenForCommand, ListenForWakeWord, MqttPublish,
PlayWavData, PlayWavFile, Problems,
ProfileTrainingComplete, ProfileTrainingFailed,
Ready, RecognizeIntent, SpeakSentence, SpeakWord,
StartRecordingToBuffer, StopListeningForWakeWord,
StopRecordingToBuffer, TestMicrophones,
TrainIntent, TrainProfile, TranscribeWav,
VoiceCommand, WakeWordDetected,
WakeWordNotDetected, WavPlayed, WavTranscription)
from rhasspy.intent import get_recognizer_class
from rhasspy.intent_handler import get_intent_handler_class
from rhasspy.intent_train import get_intent_trainer_class
+1 -1
View File
@@ -15,7 +15,7 @@ import requests
from rhasspynlu import json_to_graph, recognize
from rhasspy.actor import RhasspyActor
from rhasspy.events import RecognizeIntent, IntentRecognized, SpeakSentence
from rhasspy.events import IntentRecognized, RecognizeIntent, SpeakSentence
from rhasspy.utils import empty_intent, hass_request_kwargs
# -----------------------------------------------------------------------------
+2 -7
View File
@@ -10,13 +10,8 @@ import pydash
import requests
from rhasspy.actor import RhasspyActor
from rhasspy.events import (
HandleIntent,
IntentHandled,
SpeakSentence,
ForwardIntent,
IntentForwarded,
)
from rhasspy.events import (ForwardIntent, HandleIntent, IntentForwarded,
IntentHandled, SpeakSentence)
from rhasspy.utils import hass_request_kwargs
# -----------------------------------------------------------------------------
+4 -2
View File
@@ -13,8 +13,10 @@ from typing import Any, Dict, List, Set, Type
from urllib.parse import urljoin
from rhasspy.actor import RhasspyActor
from rhasspy.events import TrainIntent, IntentTrainingComplete, IntentTrainingFailed
from rhasspy.utils import lcm, make_sentences_by_intent, sample_sentences_by_intent
from rhasspy.events import (IntentTrainingComplete, IntentTrainingFailed,
TrainIntent)
from rhasspy.utils import (lcm, make_sentences_by_intent,
sample_sentences_by_intent)
# -----------------------------------------------------------------------------
+2 -7
View File
@@ -10,13 +10,8 @@ from typing import Any, Dict, List
import pydash
from rhasspy.actor import RhasspyActor
from rhasspy.events import (
MqttPublish,
MqttSubscribe,
MqttMessage,
MqttConnected,
MqttDisconnected,
)
from rhasspy.events import (MqttConnected, MqttDisconnected, MqttMessage,
MqttPublish, MqttSubscribe)
# -----------------------------------------------------------------------------
# Events
+3 -9
View File
@@ -7,15 +7,9 @@ from collections import defaultdict
from typing import Any, Dict, List, Optional, Tuple
from rhasspy.actor import RhasspyActor
from rhasspy.events import (
SpeakWord,
WordSpoken,
GetWordPhonemes,
WordPhonemes,
GetWordPronunciations,
WordPronunciations,
PronunciationFailed,
)
from rhasspy.events import (GetWordPhonemes, GetWordPronunciations,
PronunciationFailed, SpeakWord, WordPhonemes,
WordPronunciations, WordSpoken)
from rhasspy.utils import load_phoneme_map, read_dict
# -----------------------------------------------------------------------------
-1
View File
@@ -15,7 +15,6 @@ from rhasspy.actor import RhasspyActor
from rhasspy.events import TranscribeWav, WavTranscription
from rhasspy.utils import convert_wav, hass_request_kwargs, maybe_convert_wav
# -----------------------------------------------------------------------------
+2 -2
View File
@@ -8,10 +8,10 @@ from typing import Any, Dict, List, Optional, Type
import pywrapfst as fst
from rhasspy.actor import RhasspyActor
from rhasspy.events import TrainSpeech, SpeechTrainingComplete, SpeechTrainingFailed
from rhasspy.events import (SpeechTrainingComplete, SpeechTrainingFailed,
TrainSpeech)
from rhasspy.train.jsgf2fst import fstprintall, symbols2intent
# -----------------------------------------------------------------------------
+2 -9
View File
@@ -11,17 +11,10 @@ from urllib.parse import urljoin
import requests
from rhasspy.actor import Configured, ConfigureEvent, RhasspyActor
from rhasspy.events import (
PlayWavData,
WavPlayed,
ListenForWakeWord,
StopListeningForWakeWord,
SpeakSentence,
SentenceSpoken,
)
from rhasspy.events import (ListenForWakeWord, PlayWavData, SentenceSpoken,
SpeakSentence, StopListeningForWakeWord, WavPlayed)
from rhasspy.utils import hass_request_kwargs
# -----------------------------------------------------------------------------
+2 -1
View File
@@ -13,7 +13,8 @@ import threading
import wave
from collections import defaultdict
from pathlib import Path
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Set, Tuple
from typing import (Any, Callable, Dict, Iterable, List, Mapping, Optional,
Set, Tuple)
import pywrapfst as fst
import rhasspynlu
+4 -11
View File
@@ -11,17 +11,10 @@ from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Type
from rhasspy.actor import RhasspyActor
from rhasspy.events import (
AudioData,
StartStreaming,
StopStreaming,
MqttMessage,
MqttSubscribe,
ListenForWakeWord,
StopListeningForWakeWord,
WakeWordDetected,
WakeWordNotDetected,
)
from rhasspy.events import (AudioData, ListenForWakeWord, MqttMessage,
MqttSubscribe, StartStreaming,
StopListeningForWakeWord, StopStreaming,
WakeWordDetected, WakeWordNotDetected)
from rhasspy.utils import read_dict
# -----------------------------------------------------------------------------
+3 -3
View File
@@ -1,12 +1,12 @@
"""Tests for Rhasspy."""
import argparse
import asyncio
import json
import logging
import os
import sys
import json
import tempfile
import unittest
import logging
import argparse
from rhasspy.core import RhasspyCore