No project description provided
Project description
asrp
ASR text preprocessing utility
install
pip install asrp
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)
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)))
Speech to Hubert code
import asrp
hc = asrp.HubertCode("facebook/hubert-large-ll60k", './km_feat_100_layer_20', 20)
hc('voice file path')
Hubert code to speech
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)
Speech Enhancement
Denoiser copied from fairseq
from asrp import SpeechEnhancer
ase = SpeechEnhancer()
print(ase('./test/xxx.wav'))
usage - liveASR
- modify from https://github.com/oliverguhr/wav2vec2-live
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
Release history Release notifications | RSS feed
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.48.tar.gz
(44.5 kB
view details)
Built Distribution
asrp-0.0.48-py3-none-any.whl
(45.5 kB
view details)
File details
Details for the file asrp-0.0.48.tar.gz
.
File metadata
- Download URL: asrp-0.0.48.tar.gz
- Upload date:
- Size: 44.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91a2cffff1fa13e975d2cf01a6fefee82cf4408d5f1b5d07337b3450238a880c |
|
MD5 | c1ff74a84906257414338092424dc2c8 |
|
BLAKE2b-256 | e49101943ce535c69752db13c9f7d0b2de1e01627b123988fc36d5d918c59202 |
File details
Details for the file asrp-0.0.48-py3-none-any.whl
.
File metadata
- Download URL: asrp-0.0.48-py3-none-any.whl
- Upload date:
- Size: 45.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1977161f900693a4896d88a29755ac0b2799538745ae1a2063b0388381d0193b |
|
MD5 | 2d1619812751f8a350d62ca310a8f649 |
|
BLAKE2b-256 | 7cf8f6f51b9c9dff02521b7ef73e923a231afe44ed0b21697fa9620973a716e5 |