python - Whet trying to convert text to speech recieving this error: -
i trying contvert text speech in class assistant method:
def speak(self, phrase): tts = self.gtts(text=phrase, lang='en') tts.save(self.os.path.expanduser(r'~\response' + str(self.count) + '.mp3')) self.playsound(self.os.path.expanduser(r'~\response' + str(self.count) + '.mp3')) self.count += 1 print(phrase + "\n")
but getting error:
traceback (most recent call last): file "c:/users/r/documents/python/speechrecognition/main.py", line 5, in <module> app.mainloop() file "c:\users\r\documents\python\speechrecognition\engine\engine.py", line 120, in mainloop self.look_for_answer(self.record(), self.get_responses()) file "c:\users\r\documents\python\speechrecognition\engine\engine.py", line 50, in look_for_answer action(responses_list[key][action]) file "c:\users\r\documents\python\speechrecognition\engine\engine.py", line 41, in speak self.playsound(str(self.os.path.expanduser(r'~\response' + str(self.count) + '.mp3'))) file "c:\program files (x86)\python36-32\lib\site- packages\playsound.py", line 35, in _playsoundwin wincommand('open "' + sound + '" alias', alias) typeerror: must str, not assistant
how can solve it?
Comments
Post a Comment