bug fixes

This commit is contained in:
SevaSk 2023-05-13 11:41:10 -04:00
parent 86b97d0039
commit 5fb82347c3
2 changed files with 11 additions and 2 deletions

View File

@ -92,7 +92,7 @@ class AudioTranscriber:
if source_info["new_phrase"] or len(transcript) == 0:
if len(transcript) > MAX_PHRASES:
transcript.pop(0) # remove oldest phrase
transcript.pop(-1)
transcript.insert(0, (f"{who_spoke}: [{text}]\n\n", time_spoken))
else:
transcript[0] = (f"{who_spoke}: [{text}]\n\n", time_spoken)

View File

@ -25,12 +25,21 @@ class GPTResponder:
def respond_to_transcriber(self, transcriber):
while True:
if transcriber.transcript_changed_event.is_set():
start_time = time.time()
transcriber.transcript_changed_event.clear()
transcript_string = transcriber.get_transcript()
response = generate_response_from_transcript(transcript_string)
end_time = time.time() # Measure end time
execution_time = end_time - start_time # Calculate the time it took to execute the function
if response != '':
self.response = response
time.sleep(self.response_interval)
remaining_time = self.response_interval - execution_time
if remaining_time > 0:
time.sleep(remaining_time)
else:
time.sleep(0.3)