Error while taking input
AdityaNerpagar opened this issue · 2 comments
First i got this error =>
File ".\voice_input.py", line 26, in speak
speech.save('command.mp3')
File "C:\ProgramData\Miniconda3\lib\site-packages\gtts\tts.py", line 248, in save
with open(str(savefile), 'wb') as f:
PermissionError: [Errno 13] Permission denied: `'command.mp3
Then i fixed it by doing os.remove()
but after doing it i got another error =>
Traceback (most recent call last):
File "C:\Users\Aditya\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\Aditya\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 109, in _get_module_details
import(pkg_name)
File "C:\Users\Aditya\tars\TARS\tars2.py", line 128, in
talk('TARS is ready!')
File "C:\Users\Aditya\tars\TARS\tars2.py", line 25, in talk
os.remove("audio.mp3")
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'audio.mp3'
how and from where do i close this file.
There is a possibility another audio.mp3 in your directory is causing the problem.
Try replacing the function talk()' with a pyttsx3 function
import pyttsx3
def speak(audio):
engine = pyttsx3.init()
engine.setProperty("rate", 215)
print("TARS " + audio)
engine.say(audio)
engine.runAndWait()
#this function can replace gtts and is more stables`