Skip to content

Commit

Permalink
add interface to check whether specified language is available or not
Browse files Browse the repository at this point in the history
  • Loading branch information
xinjli committed Sep 2, 2021
1 parent 97eea48 commit f5aa296
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ model.recognize('sample.wav')

For full features and details, please refer to the following sections.

### Online Demo
There is also an online version available for allosaurus.
You can try this at [https://www.dictate.app/phone](https://www.dictate.app/phone)

![Online Demo](online_demo.png)

## Inference
The command line interface is as follows:

Expand Down
5 changes: 5 additions & 0 deletions allosaurus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def __init__(self, pm, am, lm, config):
self.lm = lm
self.config = config

def is_available(self, lang_id):
# check whether this lang id is available

return self.lm.inventory.is_available(lang_id)

def recognize(self, filename, lang_id='ipa', topk=1, emit=1.0, timestamp=False):
# recognize a single file

Expand Down
4 changes: 4 additions & 0 deletions allosaurus/lm/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def __init__(self, model_path, inference_config=None):
self.lang2phonefile[iso_id.lower()] = phone_text
self.lang2phonefile[glotto_id.lower()] = phone_text

def is_available(self, lang_id):

return lang_id in self.lang2phonefile

def get_unit(self, lang_id):
"""
load a unit specified by the lang_id
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='allosaurus',
version='1.0.1',
version='1.0.2',
description='a multilingual phone recognizer',
author='Xinjian Li',
author_email='[email protected]',
Expand Down

0 comments on commit f5aa296

Please sign in to comment.