summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/g2p.py2
-rw-r--r--client/mic.py19
-rw-r--r--client/speaker.py5
-rw-r--r--client/stt.py38
-rw-r--r--client/test.py1
5 files changed, 34 insertions, 31 deletions
diff --git a/client/g2p.py b/client/g2p.py
index 6d72bfe..bae40b6 100644
--- a/client/g2p.py
+++ b/client/g2p.py
@@ -35,7 +35,7 @@ def translateWords(words):
def translateFile(input_filename, output_filename=None):
- out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' %
+ out = subprocess.check_output(['phonetisaurus-g2p', '--model=%s' %
PHONETISAURUS_PATH + "/g014b2b.fst", '--input=%s' % input_filename, '--words', '--isfile'])
out = parseOutput(out)
diff --git a/client/mic.py b/client/mic.py
index abd16a3..01a37cb 100644
--- a/client/mic.py
+++ b/client/mic.py
@@ -16,12 +16,12 @@ class Mic:
def __init__(self, speaker, passive_stt_engine, active_stt_engine):
"""
- Initiates the pocketsphinx instance.
+ Initiates the pocketsphinx instance.
- Arguments:
- speaker -- handles platform-independent audio output
- passive_stt_engine -- performs STT while Jasper is in passive listen mode
- acive_stt_engine -- performs STT while Jasper is in active listen mode
+ Arguments:
+ speaker -- handles platform-independent audio output
+ passive_stt_engine -- performs STT while Jasper is in passive listen mode
+ acive_stt_engine -- performs STT while Jasper is in active listen mode
"""
self.speaker = speaker
self.passive_stt_engine = passive_stt_engine
@@ -34,7 +34,7 @@ class Mic:
def fetchThreshold(self):
- # TODO: Consolidate all of these variables from the next three functions
+ # TODO: Consolidate variables from the next three functions
THRESHOLD_MULTIPLIER = 1.8
RATE = 16000
CHUNK = 1024
@@ -74,8 +74,8 @@ class Mic:
def passiveListen(self, PERSONA):
"""
- Listens for PERSONA in everyday sound
- Times out after LISTEN_TIME, so needs to be restarted
+ Listens for PERSONA in everyday sound. Times out after LISTEN_TIME, so needs to be
+ restarted.
"""
THRESHOLD_MULTIPLIER = 1.8
@@ -200,8 +200,7 @@ class Mic:
frames_per_buffer=CHUNK)
frames = []
- # increasing the range # results in longer pause after command
- # generation
+ # increasing the range # results in longer pause after command generation
lastN = [THRESHOLD * 1.2 for i in range(30)]
for i in range(0, RATE / CHUNK * LISTEN_TIME):
diff --git a/client/speaker.py b/client/speaker.py
index 1b1255a..4c50a27 100644
--- a/client/speaker.py
+++ b/client/speaker.py
@@ -9,7 +9,9 @@ Speaker methods:
import os
import json
+
class eSpeakSpeaker:
+
"""
Uses the eSpeak speech synthesizer included in the Jasper disk image
"""
@@ -24,7 +26,9 @@ class eSpeakSpeaker:
def play(self, filename):
os.system("aplay -D hw:1,0 " + filename)
+
class saySpeaker:
+
"""
Uses the OS X built-in 'say' command
"""
@@ -42,6 +46,7 @@ class saySpeaker:
def play(self, filename):
os.system("afplay " + filename)
+
def newSpeaker():
"""
Returns:
diff --git a/client/stt.py b/client/stt.py
index 20150b4..1bce875 100644
--- a/client/stt.py
+++ b/client/stt.py
@@ -3,7 +3,7 @@ import json
import urllib2
"""
-The default Speech-To-Text implementation which relies on PocketSphinx.
+The default Speech-to-Text implementation which relies on PocketSphinx.
"""
@@ -13,14 +13,14 @@ class PocketSphinxSTT(object):
lmd_persona="languagemodel_persona.lm", dictd_persona="dictionary_persona.dic",
lmd_music=None, dictd_music=None, **kwargs):
"""
- Initiates the pocketsphinx instance.
+ Initiates the pocketsphinx instance.
- Arguments:
- speaker -- handles platform-independent audio output
- lmd -- filename of the full language model
- dictd -- filename of the full dictionary (.dic)
- lmd_persona -- filename of the 'Persona' language model (containing, e.g., 'Jasper')
- dictd_persona -- filename of the 'Persona' dictionary (.dic)
+ Arguments:
+ speaker -- handles platform-independent audio output
+ lmd -- filename of the full language model
+ dictd -- filename of the full dictionary (.dic)
+ lmd_persona -- filename of the 'Persona' language model (containing, e.g., 'Jasper')
+ dictd_persona -- filename of the 'Persona' dictionary (.dic)
"""
# quirky bug where first import doesn't work
@@ -39,12 +39,12 @@ class PocketSphinxSTT(object):
def transcribe(self, audio_file_path, PERSONA_ONLY=False, MUSIC=False):
"""
- Performs STT, transcribing an audio file and returning the result.
+ Performs STT, transcribing an audio file and returning the result.
- Arguments:
- audio_file_path -- the path to the audio file to-be transcribed
- PERSONA_ONLY -- if True, uses the 'Persona' language model and dictionary
- MUSIC -- if True, uses the 'Music' language model and dictionary
+ Arguments:
+ audio_file_path -- the path to the audio file to-be transcribed
+ PERSONA_ONLY -- if True, uses the 'Persona' language model and dictionary
+ MUSIC -- if True, uses the 'Music' language model and dictionary
"""
wavFile = file(audio_file_path, 'rb')
@@ -104,11 +104,11 @@ class GoogleSTT(object):
def transcribe(self, audio_file_path, PERSONA_ONLY=False, MUSIC=False):
"""
- Performs STT via the Google Speech API, transcribing an audio file
- and returning an English string.
+ Performs STT via the Google Speech API, transcribing an audio file and returning an English
+ string.
- Arguments:
- audio_file_path -- the path to the .wav file to be transcribed
+ Arguments:
+ audio_file_path -- the path to the .wav file to be transcribed
"""
url = "https://www.google.com/speech-api/v2/recognize?output=json&client=chromium&key=%s&lang=%s&maxresults=6&pfilter=2" % (
self.api_key, "en-us")
@@ -144,8 +144,8 @@ Currently, the supported implementations are the default Pocket Sphinx and
the Google Speech API
Arguments:
- engine_type - one of "sphinx" or "google"
- kwargs - keyword arguments passed to the constructor of the STT engine
+engine_type - one of "sphinx" or "google"
+kwargs - keyword arguments passed to the constructor of the STT engine
"""
diff --git a/client/test.py b/client/test.py
index 6186642..0c35cbf 100644
--- a/client/test.py
+++ b/client/test.py
@@ -11,7 +11,6 @@ import yaml
import test_mic
import g2p
import brain
-import speaker
def activeInternet():