Skip to main content

ESPnet Model Zoo

Project description

ESPnet Model Zoo

PyPI version Python Versions Downloads GitHub license Unitest Model test codecov Code style: black

Utilities managing the pretrained models created by ESPnet. This function is inspired by the Asteroid pretrained model function.

Install

pip install torch
pip install espnet_model_zoo

Python API for inference

See the next section about model_name

ASR

import soundfile
from espnet_model_zoo.downloader import ModelDownloader
from espnet2.bin.asr_inference import Speech2Text
d = ModelDownloader()
speech2text = Speech2Text(**d.download_and_unpack("model_name"))

speech, rate = soundfile.read("speech.wav")
nbests = speech2text(speech)
text, *_ = nbests[0]
print(text)

TTS

import soundfile
from espnet_model_zoo.downloader import ModelDownloader
from espnet2.bin.tts_inference import Text2Speech
d = ModelDownloader()
text2speech = Text2Speech(**d.download_and_unpack("model_name"))

speech, *_ = text2speech("foobar")
soundfile.write("out.wav", speech.numpy(), text2speech.fs, "PCM_16")

Instruction for ModelDownloader

from espnet_model_zoo.downloader import ModelDownloader
d = ModelDownloader("~/.cache/espnet")  # Specify cachedir
d = ModelDownloader()  # <module_dir> is used as cachedir by default

To obtain a model, you need to give a model name, which is listed in table.csv.

>>> d.download_and_unpack("kamo-naoyuki/mini_an4_asr_train_raw_bpe_valid.acc.best")
{"asr_train_config": <config path>, "asr_model_file": <model path>, ...}

Note that if the model already exists, you can skip downloading and unpacking.

You can also get a model with certain conditions.

d.download_and_unpack(task="asr", corpus="wsj")

If multiple models are found with the condition, the last model is selected. You can also specify the condition using "version" option.

d.download_and_unpack(task="asr", corpus="wsj", version=-1)  # Get the last model
d.download_and_unpack(task="asr", corpus="wsj", version=-2)  # Get previous model

You can also obtain it from the URL directly.

d.download_and_unpack("https://zenodo.org/record/...")

If you need to use a local model file using this API, you can also give it.

d.download_and_unpack("./some/where/model.zip")

In this case, the contents are also expanded in the cache directory, but the model is identified by the file path, so if you move the model to somewhere and unpack again, it's treated as another model, thus the contents are expanded again at another place.

Query model names

You can view the model names from our Zenodo community, https://zenodo.org/communities/espnet/, or using query(). All information are written in table.csv.

d.query("name")

You can also show them with specifying certain conditions.

d.query("name", task="asr")

Command line tools

  • espnet_model_zoo_query

    # Query model name
    espnet_model_zoo_query task=asr corpus=wsj 
    # Show all model name
    espnet_model_zoo_query
    # Query the other key
    espnet_model_zoo_query --key url task=asr corpus=wsj 
    
  • espnet_model_zoo_download

    espnet_model_zoo_download <model_name>  # Print the path of the downloaded file
    espnet_model_zoo_download --unpack true <model_name>   # Print the path of unpacked files
    
  • espnet_model_zoo_upload

    export ACCESS_TOKEN=<access_token>
    espnet_zenodo_upload \
        --file <packed_model> \
        --title <title> \
        --description <description> \
        --creator_name <your-git-account>
    

Use pretrained model in ESPnet recipe

# e.g. ASR WSJ task
git clone https://github.com/espnet/espnet
cd egs2/wsj/asr1
pip install -e .
cd egs2/wsj/asr1
./run.sh --skip_data_prep false --skip_train true --download_model kamo-naoyuki/wsj

Register your model

  1. Upload your model to Zenodo

    You need to signup to Zenodo and create an access token to upload models. You can upload your own model by using espnet_model_zoo_upload command freely, but we normally upload a model using recipes.

  2. Create a Pull Request to modify table.csv

    You need to append your record at the last line.

  3. (Administrator does) Increment the third version number of setup.py, e.g. 0.0.3 -> 0.0.4

  4. (Administrator does) Release new version

Update your model

If your model has some troubles, please modify the record at Zenodo directly or reupload a corrected file using espnet_zenodo_upload as another record.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

espnet_model_zoo-0.0.0a19.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

espnet_model_zoo-0.0.0a19-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file espnet_model_zoo-0.0.0a19.tar.gz.

File metadata

  • Download URL: espnet_model_zoo-0.0.0a19.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for espnet_model_zoo-0.0.0a19.tar.gz
Algorithm Hash digest
SHA256 9c3a2c3950b217fa7b48fb839008c108cdc68d950494bbec977a84de3a07eb5e
MD5 d7bb505d59ca63789c3d9d94d4adde1a
BLAKE2b-256 75feace037d034213343b94b45d1ca20f75f5071d97bddb4f8a3a298165b6de3

See more details on using hashes here.

File details

Details for the file espnet_model_zoo-0.0.0a19-py3-none-any.whl.

File metadata

  • Download URL: espnet_model_zoo-0.0.0a19-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

File hashes

Hashes for espnet_model_zoo-0.0.0a19-py3-none-any.whl
Algorithm Hash digest
SHA256 35642bb0ed0a0cd588fce67c353d14435cd0650d71d7332d51155a10c07a8b39
MD5 7640639283769893a03320c042d62622
BLAKE2b-256 36db9c11c461a5bad9af8c3de5d2294db000bc7a01b238b2993ff642593adf16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page