From 2e90a1a5396912849c7b7318744f1c42af0c49a8 Mon Sep 17 00:00:00 2001 From: Joseph Pan Date: Thu, 13 Jul 2017 23:14:11 +0800 Subject: [PATCH] =?UTF-8?q?flake8=20=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/alteration.py | 21 --------------------- client/conversation.py | 3 ++- client/mic.py | 11 ++++------- client/tts.py | 6 ------ test.sh | 2 +- 5 files changed, 7 insertions(+), 36 deletions(-) delete mode 100644 client/alteration.py diff --git a/client/alteration.py b/client/alteration.py deleted file mode 100644 index 91e0ad3..0000000 --- a/client/alteration.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8-*- -import re - - -def detectYears(input): - YEAR_REGEX = re.compile(r'(\b)(\d\d)([1-9]\d)(\b)') - return YEAR_REGEX.sub('\g<1>\g<2> \g<3>\g<4>', input) - - -def clean(input): - """ - Manually adjust output text before it's translated into - actual speech by the TTS system. This is to fix minior - idiomatic issues, for example, that 1901 is pronounced - "one thousand, ninehundred and one" rather than - "nineteen oh one". - - Arguments: - input -- original speech text to-be modified - """ - return detectYears(input) diff --git a/client/conversation.py b/client/conversation.py index de48746..4470037 100644 --- a/client/conversation.py +++ b/client/conversation.py @@ -4,6 +4,7 @@ from brain import Brain import time + class Conversation(object): def __init__(self, persona, mic, profile): @@ -76,4 +77,4 @@ def handleForever(self): if input: self.brain.query(input, self.wxbot) else: - self.mic.say("什么?") + self.mic.say("什么?") diff --git a/client/mic.py b/client/mic.py index cd7a09a..0b9fa43 100644 --- a/client/mic.py +++ b/client/mic.py @@ -7,12 +7,11 @@ import wave import audioop import pyaudio -import alteration import dingdangpath from app_utils import wechatUser -class Mic: +class Mic: speechRec = None speechRec_persona = None @@ -57,7 +56,7 @@ def getScore(self, data): def fetchThreshold(self): # TODO: Consolidate variables from the next three functions - THRESHOLD_MULTIPLIER = 3 + THRESHOLD_MULTIPLIER = 2.5 RATE = 16000 CHUNK = 1024 @@ -116,7 +115,7 @@ def passiveListen(self, PERSONA): needs to be restarted. """ - THRESHOLD_MULTIPLIER =3 + THRESHOLD_MULTIPLIER = 2.5 RATE = 16000 CHUNK = 1024 @@ -322,8 +321,6 @@ def activeListenToAllOptions(self, THRESHOLD=None, LISTEN=True, def say(self, phrase, OPTIONS=" -vdefault+m3 -p 40 -s 160 --stdout > say.wav"): - # alter phrase before speaking - # phrase = alteration.clean(phrase) if self.wxbot is not None: wechatUser(self.profile, self.wxbot, "%s: %s" % (self.robot_name, phrase), "") @@ -331,4 +328,4 @@ def say(self, phrase, def play(self, src): # play a voice - self.speaker.play(src) + self.speaker.play(src) diff --git a/client/tts.py b/client/tts.py index 654db10..a460b93 100644 --- a/client/tts.py +++ b/client/tts.py @@ -14,7 +14,6 @@ import subprocess import pipes import logging -import wave import urllib import requests from abc import ABCMeta, abstractmethod @@ -23,11 +22,6 @@ import argparse import yaml -try: - import mad -except ImportError: - pass - import diagnose import dingdangpath diff --git a/test.sh b/test.sh index 8982c11..705f3ee 100644 --- a/test.sh +++ b/test.sh @@ -1,2 +1,2 @@ -flake8 --exclude=wxbot.py,snowboydetect.py dingdang.py client +flake8 --exclude=wxbot.py,snowboydetect.py,client/mic_array dingdang.py client nosetests -s --exe -v --with-coverage --cover-erase