-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
29 lines (24 loc) · 792 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import sys
import keyboard
import speech_recognition as sr
from libs.helpy import translate_it
r = sr.Recognizer()
while True:
try:
if keyboard.is_pressed('0'):
with sr.Microphone() as source:
print("Talk!!")
audio_text = r.listen(source)
print("Translating...")
try:
text = r.recognize_google(audio_text)
print(f"you said: {text} \n")
translated_word = translate_it(text)
print(translated_word, '\n')
except:
print("Sorry, It's not clear.")
if keyboard.is_pressed('Esc'):
print("\n Byee...")
sys.exit(0)
except:
break