1

I have a method that I found online. The purpose of the code is for python to say words. Code for the method is below:

def respond(output):
   num=0
   print(output)
   num += 1
   response=gTTS(text=output, lang='en')
   file = str(num)+".mp3"
   response.save(file)
   playsound.playsound(file, True)  # <-- Error here.
   os.remove(file)

An error is occurring on the 7th line inside the function - playsound.playsound(file, True). I looked at another StackOverflow post where the person who had basically the same problem: Playsound throwing error "returned non-zero exit status 1", and I tried the solution that was recommended on the post. Unfortunately, I am still getting the same error. I'd like to ask if there is another solution to the problem I have.

Error message is:

Command '['/usr/bin/python3', '/usr/local/lib/python3.7/dist-packages/playsound.py', '1.mp3']'
  returned non-zero exit status 1.
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Epoch
  • 29
  • 2
  • The error message doesn't tell you much about what went wrong. I suggest that you try passing a complete (aka absolute) path to the mp3 file — you're currently only passing a relative one and the problem could simply be "file not found". – martineau Feb 04 '22 at 20:02
  • Alright, thank you. I will try that. – Epoch Feb 07 '22 at 17:49

0 Answers0