Python: Convert Speech to text and text to Speech || A Data Science Project

Опубликовано: 06 Октябрь 2024
на канале: UGC NET
236
10

Speech Recognition is an important feature in several applications used such as home automation, artificial intelligence, etc. This video aims to provide an introduction on how to make use of the SpeechRecognition and pyttsx3 library of Python. The source code of this project is given below (like and subscribe to this channel):

_______________________________________________________________________

import speech_recognition as sr
import pyttsx3


r = sr.Recognizer()


def SpeakText(command):


engine = pyttsx3.init()
engine.say(command)
engine.runAndWait()




while(1):


try:


with sr.Microphone() as source2:


r.adjust_for_ambient_noise(source2, duration=0.2)


audio2 = r.listen(source2)


MyText = r.recognize_google(audio2)
MyText = MyText.lower()

print("Did you say "+MyText)
SpeakText(MyText)

except sr.RequestError as e:
print("Could not request results; {0}".format(e))

except sr.UnknownValueError:
print("unknown error occured")

_______________________________________________________________________


Subscribe:
   / @computerscienceandapplicat8016  

follow me :   / ugc-net-108943208141515  

blog : https://computersolution2016.blogspot...

youtube channel link:    / @computerscienceandapplicat8016  
#Python #PythonProject #ProjectForStudents #python2021 #SpeechRecognition #pyttsx3 #Speechtotext #texttoSpeech