Created
May 5, 2021 17:33
-
-
Save ProjectEli/e7182f0873f8d28dbbf5eeab6781a034 to your computer and use it in GitHub Desktop.
Voice recognition with speech_recognition and google speech to text API
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
import speech_recognition | |
recognizer = speech_recognition.Recognizer() | |
with speech_recognition.Microphone() as src: | |
try: | |
audio = recognizer.adjust_for_ambient_noise(src) | |
print("Threshold Value After calibration:" + str(recognizer.energy_threshold)) | |
print("Please speak:") | |
audio = recognizer.listen(src) | |
speech_to_txt = recognizer.recognize_google(audio,language="ko-KR").lower() | |
print(speech_to_txt) | |
except Exception as ex: | |
print("Sorry. Could not understand.") | |
print("err name: " + str(ex)) | |
if (speech_to_txt == "안녕하세요"): | |
print("답변: 네 저도 안녕하세요") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment