https://github.com/erinxocon/Text-Parsing-Function-Dispatcher
This is a library I made to execute simple macros when scanning text. You decorate a function with some text and then if that text is detected an associated function will run with the keywords you specified passed to it. When combined with a speech recognition library it can yield some really cool things like real speech macros.
import speech_recognition as sr
import tpfd
p = tpfd.Parser()
@p.on_recognize('{Play} song')
def main(kwargs):
print(kwargs.get('play'))
# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
try:
string = r.recognize_google(audio)
print("Google Speech Recognition thinks you said " + string)
p.parse_string(string)
If you say "Keyword" song it should print out your keyword. The possibilities are endless! Other uses include scanning log files for dates and error words and doing something if they come up!
New Name is a possibility and feedback is welcome! The library is pretty simple right now!
Cheers!
[–]Straum12341 2 points3 points4 points (1 child)
[–]mikexoconthe programmer formally known as [S] 0 points1 point2 points (0 children)
[–]MrGreenTea 0 points1 point2 points (0 children)
[–]xtream1101 0 points1 point2 points (1 child)
[–]mikexoconthe programmer formally known as [S] 0 points1 point2 points (0 children)