Created
August 12, 2020 22:06
-
-
Save 0ex-d/0ddc7f7566ff0c11636d41be5ae394db to your computer and use it in GitHub Desktop.
Duoligot is a NLP class that uses various language processing toolset to convert your spoken words to text. Can be used in audio transcription, voice commands e.t.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__doc__ = """ | |
NLP module to convert speech-to-text, can be used | |
for extracting audio files, voice commands. | |
requires speech_recognition toolset for NLP. | |
Only works with English Language | |
By Precious Akin | |
""" | |
import speech_recognition as recognize | |
class Duoligot: | |
def alpha(self): | |
# recognizer class from lib, used for microphone input | |
recognize_speech = recognize.Recognizer() | |
with recognize.Microphone() as source: | |
print("Say something now.\n") | |
audio_data = recognize_speech.listen(source) | |
transcribed = '' | |
# try to extract text from audio | |
# or throw error if the network cannot process the language | |
try: | |
transcribed = recognize_speech.recognize_google(audio_data) | |
except recognize.UnknownValueError: | |
print("Try again..please speak clearly") | |
except recognize.RequestError: | |
print("Network error..transcription not possible.") | |
print("Transcribed: '%s'."%(transcribed)) | |
return transcribed | |
# start the program | |
if __name__ == "__main__": | |
Duoligot().alpha() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment