I want to create a file by speech Recognition and create file by SR. The problem is it only creates or delete file when I close the program.
I want to create my files while program is running, not after that. So please, can someone help?
This is my code:
def createfile():
with sr.Microphone() as source:
print("Speak now")
audio = mic1.listen(source)
cmd = mic2.recognize_google(audio) # convert audio into string
print(mic2.recognize_google(audio))
create_UC(cmd)
def create_UC(cmd):
if "create" in cmd.lower():
fileName = fileName + ".txt"
print(fileName)
if os.path.exists(not fileName):
f = open(fileName, 'w+')
f.close()
else:
showinfo("Error", "Sorry, File Already Exist!")