Reputation: 533
I'm trying to implement a speech recognition system to call commands (CMD module). As the SR libraries don't recognize everything, I'd like to leave an open door to be able to call certain commands by a text input as well. What I don't know if is possible is to wait for inputs from different sources, something like this:
def get_input():
my_input = input('> ') or audio_input()
return my_input
Obviously, if the source is an audio, it has to be processed to get the text, so I'd also like to have a flag to recognize what type did the user send, either text or audio.
Is there a way to do something like this? Thanks a lot!
Upvotes: 2
Views: 1195
Reputation: 794
As johnsharpe wrote in the comment, the behaviour on your code seems fine. If you want to check for the two inputs at the same time and work on the first that comes out, you'll need some sort of multithreading, which complicates a little the issue. You could start checking out the python multithreading package.
As far as recognition of the input type, I imagine textual input will be a string, while the audio some other kind of object. Once you collect your input you could just check the kind of object by using isinstance
.
Upvotes: 1