Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

assistant - Google text to speech module error in .save() function python

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...