Python Text To Spesdfssech
Python Text To Spesdfssech
import pyttsx3
# using microphone to listen for audio input and if possible turn audio into
string
def record_text():
#loop in case of errors
while(1):
try:
# use microphone as a source of input
with sr.Microphone() as source2:
# Prepare the recognizer to receive input
r.adjust_for_ambient_noise(source2, duration=0.2)
except sr.RequestError as e:
print("Could not request results: {0}".format(e))
except sr.UnknownValueError:
print("unknown error occurred")
# take string and output it to a text file to complete speech to text program
def output_text(text):
# allows to access the output.txt file and storing the access in the f
variable
f = open("output.txt", "a")
f.write(text)
f.write("/n")
f.close()
return