Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

20ECP118: Foundations of AI Applications Lab

Prepared By: Divneet Singh Kapoor & Kiran Jot Singh

Worksheet
EXPERIMENT – 4
Aim:
Perform Speech-to-text conversion using pre trained machine learning API models for short-
form or long-form audio.
Requirements:
PC with internet connectivity, Python 3.7
Expected Outcome:
 List down all the commands used

CODE:

import speech_recognition as sr

r = sr.Recognizer()

mic = sr.Microphone(device_index=1)

with mic as source:


r.adjust_for_ambient_noise(source, duration=1)
print("Say your name & UID")
audio = r.listen(source, timeout=10)
print(" Thank you !!")

try:
print("Name & UID :" + r.recognize_google(audio));
except:
print("Sorry!unable to understand")
pass;
20ECP118: Foundations of AI Applications Lab

Prepared By: Divneet Singh Kapoor & Kiran Jot Singh

OUTPUT:

You might also like