Merge pull request #532 from alibaba-damo-academy/dev_lhn

Dev lhn
This commit is contained in:
hnluo 2023-05-19 13:38:52 +08:00 committed by GitHub
commit c4e37cb6c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -34,6 +34,6 @@ for sample_offset in range(0, speech_length, min(stride_size, speech_length - sa
rec_result = inference_pipeline(audio_in=speech[sample_offset: sample_offset + stride_size],
param_dict=param_dict)
if len(rec_result) != 0:
final_result += rec_result['text'] + " "
final_result += rec_result['text']
print(rec_result)
print(final_result)

View File

@ -34,6 +34,6 @@ for sample_offset in range(0, speech_length, min(stride_size, speech_length - sa
rec_result = inference_pipeline(audio_in=speech[sample_offset: sample_offset + stride_size],
param_dict=param_dict)
if len(rec_result) != 0:
final_result += rec_result['text'] + " "
final_result += rec_result['text']
print(rec_result)
print(final_result.strip())

View File

@ -9,6 +9,7 @@ import sys
import time
import copy
import os
import re
import codecs
import tempfile
import requests
@ -828,9 +829,16 @@ class Speech2TextParaformerOnline:
# Change integer-ids to tokens
token = self.converter.ids2tokens(token_int)
token = " ".join(token)
results.append(token)
postprocessed_result = ""
for item in token:
if item.endswith('@@'):
postprocessed_result += item[:-2]
elif re.match('^[a-zA-Z]+$', item):
postprocessed_result += item + " "
else:
postprocessed_result += item
results.append(postprocessed_result)
# assert check_return_type(results)
return results