Skip to main content

No project description provided

Project description

asrp

ASR text preprocessing utility

install

pip install asrp

usage - preprocess

input: dictionary, with key sentence
output: preprocessed result, inplace handling.

import asrp

batch_data = {
    'sentence': "I'm fine, thanks."
}
asrp.fun_en(batch_data)

dynamic loading

import asrp

batch_data = {
    'sentence': "I'm fine, thanks."
}
preprocessor = getattr(asrp, 'fun_en')
preprocessor(batch_data)

usage - evaluation

import asrp

targets = ['HuggingFace is great!', 'Love Transformers!', 'Let\'s wav2vec!']
preds = ['HuggingFace is awesome!', 'Transformers is powerful.', 'Let\'s finetune wav2vec!']
print("chunk size WER: {:2f}".format(100 * asrp.chunked_wer(targets, preds, chunk_size=None)))
print("chunk size CER: {:2f}".format(100 * asrp.chunked_cer(targets, preds, chunk_size=None)))

usage - hubertcode

import asrp

hc = asrp.HubertCode("facebook/hubert-large-ll60k", './km_feat_100_layer_20', 20)
hc('voice file path')

usage - code2speech

import asrp

code = []  # discrete unit
# download tts checkpoint and waveglow_checkpint from https://github.com/pytorch/fairseq/tree/main/examples/textless_nlp/gslm/unit2speech
cs = asrp.Code2Speech(tts_checkpoint='./tts_checkpoint_best.pt', waveglow_checkpint='waveglow_256channels_new.pt')
cs(code)

# play on notebook
import IPython.display as ipd

ipd.Audio(data=cs(code), autoplay=False, rate=cs.sample_rate)

usage - liveASR

from asrp.live import LiveHFSpeech

english_model = "voidful/wav2vec2-xlsr-multilingual-56"
asr = LiveHFSpeech(english_model, device_name="default")
asr.start()

try:
    while True:
        text, sample_length, inference_time = asr.get_last_text()
        print(f"{sample_length:.3f}s"
              + f"\t{inference_time:.3f}s"
              + f"\t{text}")

except KeyboardInterrupt:
    asr.stop()

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

asrp-0.0.44.tar.gz (7.0 MB view details)

Uploaded Source

Built Distribution

asrp-0.0.44-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file asrp-0.0.44.tar.gz.

File metadata

  • Download URL: asrp-0.0.44.tar.gz
  • Upload date:
  • Size: 7.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for asrp-0.0.44.tar.gz
Algorithm Hash digest
SHA256 5810405d7d518d86c977123c69f10ec10ecb6bd451a96f8ea75a780e736fe765
MD5 d94ec72399e1b3055c3be9d12aab3f41
BLAKE2b-256 50b7309b107d915bb946801bed311ef6ca1a90867a09c054a7f1270190c251d2

See more details on using hashes here.

File details

Details for the file asrp-0.0.44-py3-none-any.whl.

File metadata

  • Download URL: asrp-0.0.44-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.10

File hashes

Hashes for asrp-0.0.44-py3-none-any.whl
Algorithm Hash digest
SHA256 0de2d3b7d81231540c16cd9b9e554cda88ccedad448feac55216d6813035154b
MD5 f3b09e65a0eb8547a8ac1b9e3a59e37a
BLAKE2b-256 51e9bbc121c46376dd1719182515b0ffbeaf58615b9ec36dcbe83648611cdb56

See more details on using hashes here.

Supported by

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