|
@@ -69,8 +69,8 @@ class TestSt:
|
|
|
return None
|
|
|
|
|
|
def __init__(self, tid, message_receiver=None):
|
|
|
- self.is_closed = False
|
|
|
- self.lock = threading.Lock()
|
|
|
+ # self.is_closed = False
|
|
|
+ # self.lock = threading.Lock()
|
|
|
|
|
|
self.__th = threading.Thread(target=self.__test_run)
|
|
|
self.__id = tid
|
|
@@ -83,25 +83,25 @@ class TestSt:
|
|
|
self.__th.start()
|
|
|
|
|
|
def send_audio(self, audio_data):
|
|
|
- # if self.sr:
|
|
|
- # # print("Sending audio data of length:", len(audio_data))
|
|
|
- # self.sr.send_audio(audio_data)
|
|
|
- # print("Audio data sent.")
|
|
|
- if self.sr and not self.is_closed:
|
|
|
- with self.lock:
|
|
|
- try:
|
|
|
- self.sr.send_audio(audio_data)
|
|
|
- except Exception as e:
|
|
|
- print(f"Error sending audio: {e}")
|
|
|
- self.close()
|
|
|
- def close(self):
|
|
|
- with self.lock:
|
|
|
- if not self.is_closed:
|
|
|
- self.is_closed = True
|
|
|
- try:
|
|
|
- self.sr.stop()
|
|
|
- except Exception as e:
|
|
|
- print(f"Error stopping ASR: {e}")
|
|
|
+ if self.sr:
|
|
|
+ # print("Sending audio data of length:", len(audio_data))
|
|
|
+ self.sr.send_audio(audio_data)
|
|
|
+ print("Audio data sent.")
|
|
|
+ # if self.sr and not self.is_closed:
|
|
|
+ # with self.lock:
|
|
|
+ # try:
|
|
|
+ # self.sr.send_audio(audio_data)
|
|
|
+ # except Exception as e:
|
|
|
+ # print(f"Error sending audio: {e}")
|
|
|
+ # self.close()
|
|
|
+ # def close(self):
|
|
|
+ # with self.lock:
|
|
|
+ # if not self.is_closed:
|
|
|
+ # self.is_closed = True
|
|
|
+ # try:
|
|
|
+ # self.sr.stop()
|
|
|
+ # except Exception as e:
|
|
|
+ # print(f"Error stopping ASR: {e}")
|
|
|
|
|
|
def __test_run(self):
|
|
|
print("Thread:{} start..".format(self.__id))
|