Im having trouble with making an assistant. To make it I need gtts module in python.
However it works perfectly fine. When i tried the second time it results in a errno.13 permission error.
Code is
from gtts import gTTS
import speech_recognition as sr
import os
import playsound
keeprunning = True
WAKING = "HEY GOOGLE"
def speak(text):
speaker = gTTS(text = text, lang = "en")
speaker.save("Voice.mp3")
playsound.playsound("voice.mp3")
#Main controlling part here(Oof!)
def Control(comnd):
if "WHO ARE YOU" in comnd:
speak("I am an idiot")
#Main controlling part ends
def listen():
r = sr.Recognizer()
with sr.Microphone() as source:
listen = r.listen(source)
try:
text = r.recognize_google(listen)
return text.upper()
except:
speak("Sorry, we had an error. Please try again")
def KeepListening():
while keeprunning:
text = listen()
if "HEY GOOGLE" in text:
speak("I am listening...")
text = listen()
Control(text)
text = listen()
text = text
print(text)
if not text == "NONE":
if WAKING in text:
speak("I am listening...")
text = listen()
print(text)
speak("idiot")
Can anyone plz help me? Also i Tried changing the permission to read and write the file.
IN case you need to try it out just download the gtts module and speech recognition. Also after you run the program wait for a 4 seconds and say hey google. it will respond and try saying something a second time and it gives the error## Heading ##
question from:
https://stackoverflow.com/questions/65917593/google-text-to-speech-module-error-in-save-function-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…