fix: chat chroma chat and add opencc convert to asr

This commit is contained in:
0Xiao0
2024-09-20 18:07:59 +08:00
parent 8461555a58
commit 395500205a
2 changed files with 31 additions and 6 deletions

View File

@ -16,12 +16,18 @@ import tempfile
import json
import os
import opencc
from ..configuration import SenseVoiceConf
from ..log.logging_time import logging_time
import logging
logger = logging.getLogger(__name__)
converter = opencc.OpenCC('s2t.json')
@singleton
class ASR(Blackbox):
mode: str
@ -98,17 +104,20 @@ class ASR(Blackbox):
os.remove(temp_audio_path)
if len(results) == 0:
return None
results = converter.convert(results)
return results
elif user_model_name == 'funasr' or ['funasr']:
results = converter.convert(results)
return results
else:
results = self.paraformer([BytesIO(data)])
if len(results) == 0:
return None
return results[0]
results = converter.convert(results[0])
return results
def valid(self, data: any) -> bool:
if isinstance(data, bytes):