Formatting

pull/19/head
Matthew Scholefield 2018-07-10 16:08:28 -05:00
parent afbace91b1
commit 1f5e17ba0a
14 changed files with 30 additions and 38 deletions

View File

@ -11,14 +11,13 @@
# 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 numpy as np
from abc import abstractmethod, ABCMeta
from importlib import import_module
from os.path import splitext
from typing import *
from typing import BinaryIO
import numpy as np
from precise.model import load_precise_model
from precise.params import inject_params
from precise.util import buffer_to_audio

View File

@ -11,11 +11,12 @@
# 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.
from math import floor
import attr
import json
from os.path import isfile
import json
from math import floor
import attr
@attr.s(frozen=True)
class ListenerParams:

View File

@ -12,11 +12,10 @@
# 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 numpy as np
from typing import *
from typing import BinaryIO
import numpy as np
from precise.params import pr
from precise.util import audio_to_buffer

View File

@ -12,15 +12,14 @@
# 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.
from prettyparse import create_parser
from random import randint
from threading import Event
from prettyparse import create_parser
from precise.pocketsphinx.listener import PocketsphinxListener
from precise.util import activate_notify
from precise_runner import PreciseRunner
from precise_runner.runner import ListenerEngine
from precise.util import activate_notify
usage = '''
Run Pocketsphinx on microphone audio input

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import wave
from subprocess import check_output, PIPE
from prettyparse import create_parser
from subprocess import check_output, PIPE
from precise.pocketsphinx.listener import PocketsphinxListener
from precise.scripts.test import show_stats, Stats

View File

@ -12,15 +12,15 @@
# 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 tty
import wave
from os.path import isfile
from select import select
from sys import stdin
from termios import tcsetattr, tcgetattr, TCSADRAIN
from prettyparse import create_parser
import pyaudio
import tty
import wave
from os.path import isfile
from prettyparse import create_parser
usage = '''
Record audio samples for use with precise
@ -66,8 +66,8 @@ EXIT_KEY_CODE = 27
def record_until(p, should_return, args):
chunk_size = 1024
stream = p.open(format=p.get_format_from_width(args.width), channels=args.channels, rate=args.rate,
input=True, frames_per_buffer=chunk_size)
stream = p.open(format=p.get_format_from_width(args.width), channels=args.channels,
rate=args.rate, input=True, frames_per_buffer=chunk_size)
frames = []
while not should_return():

View File

@ -15,9 +15,8 @@
# limitations under the License.
import os
from os.path import split, isfile
from shutil import copyfile
from prettyparse import create_parser
from shutil import copyfile
usage = '''
Convert wake word model from Keras to TensorFlow

View File

@ -12,9 +12,9 @@
# 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
import sys
import os
from prettyparse import create_parser
from precise import __version__

View File

@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
from os.path import isfile, isdir
from prettyparse import create_parser

View File

@ -12,13 +12,12 @@
# 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 numpy as np
from os.path import join
from prettyparse import create_parser
from random import randint
from threading import Event
import numpy as np
from prettyparse import create_parser
from precise.network_runner import Listener
from precise.util import save_audio, buffer_to_audio, activate_notify
from precise_runner import PreciseRunner
@ -74,7 +73,8 @@ def main():
engine = ListenerEngine(listener, args.chunk_size)
engine.get_prediction = get_prediction
runner = PreciseRunner(engine, args.threshold, on_activation=on_activation, on_prediction=on_prediction)
runner = PreciseRunner(engine, args.threshold, on_activation=on_activation,
on_prediction=on_prediction)
runner.start()
Event().wait() # Wait forever

View File

@ -16,7 +16,6 @@ from collections import namedtuple
from prettyparse import create_parser
from precise.model import load_precise_model
from precise.network_runner import Listener
from precise.params import inject_params
from precise.train_data import TrainData

View File

@ -12,18 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import numpy as np
from argparse import ArgumentParser
from contextlib import suppress
from glob import glob
from hashlib import md5
from os.path import join, isfile, dirname
from os.path import join, isfile
from prettyparse import add_to_parser
from typing import *
import numpy as np
from prettyparse import add_to_parser
from precise.util import find_wavs
from precise.vectorization import load_vector, vectorize_inhibit, vectorize
from precise.vectorization import load_vector, vectorize_inhibit
class TrainData:

View File

@ -11,10 +11,9 @@
# 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.
from typing import *
import numpy as np
from os.path import join, dirname, abspath
from typing import *
from precise.params import pr
@ -55,6 +54,7 @@ def save_audio(filename: str, audio: np.ndarray):
save_audio = (audio * np.iinfo(np.int16).max).astype(np.int16)
wavio.write(filename, save_audio, pr.sample_rate, sampwidth=pr.sample_depth, scale='none')
def play_audio(filename: str):
"""
Args:
@ -66,12 +66,14 @@ def play_audio(filename: str):
player = 'play' if platform.system() == 'Darwin' else 'aplay'
Popen([player, '-q', filename])
def activate_notify():
audio = 'data/activate.wav'
audio = abspath(dirname(abspath(__file__)) + '/../' + audio)
play_audio(audio)
def glob_all(folder: str, filt: str) -> List[str]:
"""Recursive glob"""
import os

View File

@ -12,10 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import hashlib
from typing import *
import json
import numpy as np
from typing import *
from precise.params import pr
from precise.util import load_audio