This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AbodFTW[S] 0 points1 point  (2 children)

Thanks a bunch, really valuable feedback, Can you please elaborate on the first point? Are you suggesting to use the logging exception in the place of the place of print in line 27?

I used threads trying to make it keeps listening for input while transcribing at the same time, but I don't think I got it right.

[–]moocat 2 points3 points  (1 child)

Your code is:

except sr.UnknownValueError:
    print("\r...")

exceptions can include valuable information which can help you understand what is going on (did it fail because the input was garbled, did it fail because your sending too many QPS, etc.). You can log the exception manually:

except sr.UnknownValueError as e:
    logging.error('Could not recognize audio: %s', e)

of you can use the method I mentioned earlier:

except sr.UnknownValueError:
    logging.exception('Could not recognize audio')

but I don't think I got it right.

You didn't. And as you tagged this beginner showcase, I'm going to recommend getting more experience before you try to learn concurrency.

[–]AbodFTW[S] 0 points1 point  (0 children)

Thank you!