Skip to content

Commit

Permalink
✨ feat: Trying to limit max time in question
Browse files Browse the repository at this point in the history
  • Loading branch information
luisffee committed Oct 23, 2024
1 parent 6be1c09 commit 2538c8c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nodes/speech_recognizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ def handle_recognition(req):
})

try:
start_time = time.time() # Start the timer
# Initialize the audio-to-text recorder with the configurations
with AudioToTextRecorder(**configs) as recorder:
# Get the recognized text
text = recorder.text()
elapsed_time = time.time() - start_time # Calculate elapsed time
if elapsed_time > 7:
raise TimeoutError("Recording exceeded 7 seconds")
try:
# Shutdown the recorder
AudioToTextRecorder.shutdown()
Expand Down

0 comments on commit 2538c8c

Please sign in to comment.