From f9d4aae1bf3dcc5e6b75bfd1f6e68d2e69d81ad4 Mon Sep 17 00:00:00 2001 From: "Brian J. Tarricone" Date: Sun, 29 Mar 2020 00:53:47 -0700 Subject: [PATCH] Update for deepspeech 0.6.x --- app.py | 17 ++++++++--------- config.yaml | 9 +++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app.py b/app.py index bbc4a60..6fca12f 100755 --- a/app.py +++ b/app.py @@ -23,14 +23,13 @@ def load_config(): def create_model(config): d = config['deepspeech'] - model = deepspeech.Model(d['model'], int(d.get('num_features', '26')), - int(d.get('num_context', '9')), d['alphabet'], - int(d.get('beam_width', '512'))) + model = deepspeech.Model(d['model'], + int(d.get('beam_width', '500'))) if 'lm' in d and 'trie' in d: - model.enableDecoderWithLM(d['alphabet'], d['lm'], d['trie'], - float(d.get('lm_weight', '1.5')), - float(d.get('valid_word_count_weight', '2.25'))) + model.enableDecoderWithLM(d['lm'], d['trie'], + float(d.get('lm_alpha', '0.75')), + float(d.get('lm_beta', '1.85'))) return model @@ -45,9 +44,9 @@ def __init__(self, model): def _update_exec_time(self, start_time): self.exec_time += time.perf_counter() - start_time - async def setupStream(self): + async def createStream(self): self._last_sample_time = time.perf_counter() - self._stream_ctx = await sync_to_async(self._model.setupStream)() + self._stream_ctx = await sync_to_async(self._model.createStream)() self._update_exec_time(self._last_sample_time) async def feedRawAudioContent(self, frames): @@ -94,7 +93,7 @@ async def handle_stt(request): logging.info("Processing Stream...") start_time = time.perf_counter() ctx = ASyncContext(model) - await ctx.setupStream() + await ctx.createStream() fmt = request.query.get('format', 'wav') diff --git a/config.yaml b/config.yaml index 997a4bc..f6430c9 100644 --- a/config.yaml +++ b/config.yaml @@ -1,13 +1,10 @@ deepspeech: model: models/output_graph.pbmm - alphabet: models/alphabet.txt lm: models/lm.binary trie: models/trie - lm_weight: 1.5 - num_features: 26 - num_context: 9 - beam_width: 512 - valid_word_count_weight: 2.25 + lm_alpha: 0.75 + lm_beta: 1.85 + beam_width: 500 server: host: '0.0.0.0' port: 8080