()
| 15 | |
| 16 | |
| 17 | def takeCommand(): |
| 18 | r = sr.Recognizer() |
| 19 | with sr.Microphone() as source: |
| 20 | print("Listening...") |
| 21 | r.pause_threshold = 1 |
| 22 | r.energy_threshold = 494 |
| 23 | r.adjust_for_ambient_noise(source, duration=1.5) |
| 24 | audio = r.listen(source) |
| 25 | |
| 26 | try: |
| 27 | print("Recognizing..") |
| 28 | query = r.recognize_google(audio, language="en-in") |
| 29 | print(f"User said: {query}\n") |
| 30 | |
| 31 | except Exception: |
| 32 | # print(e) |
| 33 | |
| 34 | print("Say that again please...") |
| 35 | return "None" |
| 36 | return query |
| 37 | |
| 38 | |
| 39 | def translate(word): |