Skip to content

Commit

Permalink
Patch decoding for PC models (#6630) (#6631)
Browse files Browse the repository at this point in the history
* Patch decoding logic for PC models



* Patch decoding logic for PC models



---------

Signed-off-by: smajumdar <titu1994@gmail.com>
Co-authored-by: Somshubra Majumdar <titu1994@gmail.com>
  • Loading branch information
github-actions[bot] and titu1994 authored May 11, 2023
1 parent 3fb6b87 commit 0ccb944
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nemo/collections/asr/metrics/rnnt_wer.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
# limitations under the License.

import copy
import re
from abc import abstractmethod
from dataclasses import dataclass, is_dataclass
from typing import Callable, Dict, List, Optional, Tuple, Union
@@ -499,6 +500,10 @@ def decode_hypothesis(self, hypotheses_list: List[Hypothesis]) -> List[Union[Hyp
else:
hypothesis = self.decode_tokens_to_str(prediction)

# TODO: remove
# collapse leading spaces before . , ? for PC models
hypothesis = re.sub(r'(\s+)([\.\,\?])', r'\2', hypothesis)

if self.compute_hypothesis_token_set:
hypotheses_list[ind].tokens = self.decode_ids_to_tokens(prediction)

5 changes: 5 additions & 0 deletions nemo/collections/asr/metrics/wer.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
from abc import abstractmethod
from dataclasses import dataclass, is_dataclass
from typing import Callable, Dict, List, Optional, Tuple, Union
@@ -540,6 +541,10 @@ def decode_hypothesis(
else:
hypothesis = self.decode_tokens_to_str(decoded_prediction)

# TODO: remove
# collapse leading spaces before . , ? for PC models
hypothesis = re.sub(r'(\s+)([\.\,\?])', r'\2', hypothesis)

# Preserve this wrapped hypothesis or decoded text tokens.
hypotheses_list[ind].text = hypothesis

0 comments on commit 0ccb944

Please sign in to comment.