Reputation: 27
I have built a chatbot that allows users to replay the latest message. The replay function is connected to the tkinter GUI, and uses pyttsx3 to "speak" an output when a replay button is pressed.
def speak(message):
engine = pyttsx3.init()
voices = engine.getProperty('voices') # Get available voices
engine.setProperty('voice', voices[0].id) # Set the voice
engine.setProperty('rate', 200)
engine.say(message)
engine.runAndWait()
return "Your message was spoken!"
Here is the linking:
play_button = Button(bottom_label, text="Replay", font=FONT_BOLD, width=20, bg=BG_VIOLET,
command=lambda: speak(last_message))
play_button.place(relx=0.01, rely=0.008, relheight=0.06, relwidth=0.22)
The replay button and speak function works perfectly fine in the IDE when i click run. However, When I created the executable, and tried to replay a message, there was no audio output. It is definitely not an issue with the audio settings, but an issue with the code / executable. How do I fix it?
Upvotes: 0
Views: 43
Reputation: 750
I install pyttsx3 and pyinstaller, and build the following demo code to exe with this command pyinstaller main.py
. There is an audio output.
import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()
Here is the package version:
See if you could solve the issue by updating the packages. If the version is already the same, you can upload a simple demo and I will build it to exe.
Upvotes: 0