speech audio to text code example
Example 1: text to speech
import pyttsx3
engine = pyttsx3.init()
engine.say("")
engine.runAndWait()
Example 2: speech to text
import speech_recognition as sr
def mycommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("listening....")
r.pause_threshold = 1
audio = r.listen(source)
query = mycommand()
print(query)
#prints whatever you said