summaryrefslogtreecommitdiff
path: root/realtime/rt/decoder.py
diff options
context:
space:
mode:
Diffstat (limited to 'realtime/rt/decoder.py')
-rw-r--r--realtime/rt/decoder.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/realtime/rt/decoder.py b/realtime/rt/decoder.py
index e6e7489d..ed45c248 100644
--- a/realtime/rt/decoder.py
+++ b/realtime/rt/decoder.py
@@ -13,13 +13,14 @@ class Decoder:
if not force:
self.lock.acquire()
self.decoder.stdin.close()
+ self.decoder.wait()
if not force:
self.lock.release()
def decode(self, sentence, grammar=None):
'''Threadsafe, FIFO'''
- input = '<seg grammar="{g}">{s}</seg>\n'.format(s=sentence, g=grammar) if grammar else '{}\n'.format(sentence)
self.lock.acquire()
+ input = '<seg grammar="{g}">{s}</seg>\n'.format(s=sentence, g=grammar) if grammar else '{}\n'.format(sentence)
self.decoder.stdin.write(input)
hyp = self.decoder.stdout.readline().strip()
self.lock.release()
@@ -71,8 +72,8 @@ class MIRADecoder(Decoder):
def update(self, sentence, grammar, reference):
'''Threadsafe, FIFO'''
- input = 'LEARN ||| <seg grammar="{g}">{s}</seg> ||| {r}\n'.format(s=sentence, g=grammar, r=reference)
self.lock.acquire()
+ input = 'LEARN ||| <seg grammar="{g}">{s}</seg> ||| {r}\n'.format(s=sentence, g=grammar, r=reference)
self.decoder.stdin.write(input)
log = self.decoder.stdout.readline().strip()
self.lock.release()