Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -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')

Expand Down
9 changes: 3 additions & 6 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -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