i have created a project text to speech in python kivy, i want to save the converted speech file as.mp3 or.wav file. i tried but i cannot save as audio file.
here, i don't know how to save the converted speech as audio file
def say_something(self, text):
try:
engine = pyttsx3.init()
engine.setProperty('rate', 160)
engine.setProperty('volume', 0.9)
text1 = engine.say(text)
engine.save_to_file(text, 'text_input.mp3')
engine.runAndWait()
#save function
def show_save(self):
content = SaveDialog(save=self.save, cancel=self.dismiss_popup)
self._popup = Popup(title="Save file", content=content,
size_hint=(0.9, 0.9))
self._popup.open()
def save(self, path, filename):
with open(os.path.join(path, filename), 'wb') as stream:
stream.write(self.text1)
self.dismiss_popup()
try this,
myobj=gTTS(text=mytext,lang=language,slow=True)
myobj.save("welcome1.mp3")
Hope this is useful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.