From 35c953a99cd9cb477f4919cec0f86ebb1137188d Mon Sep 17 00:00:00 2001 From: Wannaphong Phatthiyaphaibun Date: Thu, 11 Aug 2022 16:56:40 +0700 Subject: [PATCH] PyThaiASR v1.1.1 - Fixed bug with wav2vec2 (non-lm) --- pythaiasr/__init__.py | 6 ++++-- setup.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pythaiasr/__init__.py b/pythaiasr/__init__.py index 9bac88c..3f82993 100644 --- a/pythaiasr/__init__.py +++ b/pythaiasr/__init__.py @@ -52,8 +52,10 @@ def __call__(self, file: str) -> str: input_dict = self.processor(a["input_values"][0], return_tensors="pt", padding=True) logits = self.model(input_dict.input_values).logits pred_ids = torch.argmax(logits, dim=-1)[0] - - txt = self.processor.batch_decode(logits.detach().numpy()).text[0] + if self.model_name == "airesearch/wav2vec2-large-xlsr-53-th": + txt = self.processor.decode(pred_ids).replace(' ','') + else: + txt = self.processor.batch_decode(logits.detach().numpy()).text[0] return txt _model_name = "airesearch/wav2vec2-large-xlsr-53-th" diff --git a/setup.py b/setup.py index 50e533e..f785cf8 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def read(*paths): setup( name='pythaiasr', - version='1.1.0', + version='1.1.1', packages=['pythaiasr'], url='https://github.com/pythainlp/pythaiasr', license='Apache Software License 2.0',