‘SpeechRecognition‘ klasini ishlatishdan oldin uni ‘cmd’ orqali usatnovka qilib olamiz.
Quyidagi kod orqali ‘SpeechRecognition’ klasini testlab olishimiz mumkin:
python -m speech_recognition
import speech_recognition as sr
# get audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
print("Tinglash:")
audio = r.listen(source)
try:
print("Sizning so`zlaringniz " + r.recognize_google(audio))
except sr.UnknownValueError:
print("Eshitishda xatolik")
except sr.RequestError as e:
print("Natija chiqarish mumkin emas; {0}".format(e))
Do'stlaringiz bilan baham: |