Skip to content

Commit

Permalink
Adapted recording functionality to new cli
Browse files Browse the repository at this point in the history
  • Loading branch information
louiskirsch committed Apr 22, 2017
1 parent b8ef3f0 commit 9eeb0ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ ENV/
# Created files by program
/data/
/train/
/logs/
/log/
4 changes: 2 additions & 2 deletions speecht/record_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def record(self):
it without getting chopped off.
"""
stream = self._pyaudio.open(format=self.format, channels=1, rate=self.rate,
input=True, output=True,
frames_per_buffer=self.chunk_size)
input=True, output=True,
frames_per_buffer=self.chunk_size)

num_silent = 0
snd_started = False
Expand Down
7 changes: 4 additions & 3 deletions speecht/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from speecht.evaluation import Evaluation
from speecht.speech_input import SingleInputLoader
from speecht.speech_model import create_default_model
import speecht.vocabulary

from speecht import preprocessing

Expand All @@ -35,12 +36,12 @@ def run(self):
speech_input_loader = SingleInputLoader(self.flags.input_size)

sample_rate = 16000
recorder = AudioRecorder(rate=sample_rate)
recorder = AudioRecorder(rate=sample_rate, chunk_size=4 * 1024)

with tf.Session() as sess:

model = create_default_model(self.flags, self.flags.input_size, speech_input_loader)
model.restore(sess, self.flags.run_data_dir)
model.restore(sess, self.flags.run_train_dir)

while True:
print('Recording audio')
Expand All @@ -64,6 +65,6 @@ def run(self):
decoded_ids_paths = [Evaluation.extract_decoded_ids(path) for path in decoded]
for decoded_path in decoded_ids_paths:
decoded_ids = next(decoded_path)
decoded_str = vocabulary.ids_to_sentence(decoded_ids)
decoded_str = speecht.vocabulary.ids_to_sentence(decoded_ids)
print('decoded: {}'.format(decoded_str))

0 comments on commit 9eeb0ec

Please sign in to comment.