From ae6e0cfc41252e394e775427c87fb291e4e78b28 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 4 Sep 2024 18:53:44 +0800 Subject: [PATCH] bugfix --- rtcllm/rtc.py | 4 ++-- rtcllm/stt.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rtcllm/rtc.py b/rtcllm/rtc.py index fe28b5c..a79724a 100644 --- a/rtcllm/rtc.py +++ b/rtcllm/rtc.py @@ -44,7 +44,7 @@ RTCPeerConnection.get_local_candidates = pc_get_local_candidates class RTCLLM: def __init__(self, ws_url, iceServers): - self.stt_model = WhisperModel('large-v3', device="cuda", compute_type="float16") + # self.stt_model = WhisperModel('large-v3', device="cuda", compute_type="float16") self.ws_url = ws_url self.iceServers = iceServers self.peers = DictObject() @@ -101,7 +101,7 @@ class RTCLLM: self.onlineList = data.onlineList async def vad_voiceend(self, peer, audio): - ret = await asr(self.stt_model, audio) + ret = await asr(audio) # await peer.dc.send(txt) diff --git a/rtcllm/stt.py b/rtcllm/stt.py index 57a7187..0ffee7b 100644 --- a/rtcllm/stt.py +++ b/rtcllm/stt.py @@ -30,11 +30,11 @@ opts = { "asr":desc } -async def asr(model, a_file): - """ +async def asr(a_file): oc = OAuthClient(DictObject(**opts)) - r = await oc("http://open-computing.cn", "asr", {"b64audio":audio}) - print(f'{r=}') + with open(a_file, 'rb') as f: + r = await oc("http://open-computing.cn", "asr", {"audio_file":f}) + print(f'{r=}') """ segments, info = model.transcribe(a_file, beam_size=5) txt = '' @@ -44,3 +44,4 @@ async def asr(model, a_file): 'content': txt, 'language': info.language } + """