Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Q&A
Unable to use pyttx3 (libespeak.so.1: cannot open shared object file: No such file or directory)
from tkinter import * from tkinter import messagebox, filedialog import pyttsx3 import PyPDF2 import os import webbrowser root = Tk() # root.geometry("500x500") root.title("Audio Book") ...
#1: Initial revision
Unable to use pyttx3 (libespeak.so.1: cannot open shared object file: No such file or directory)
```python from tkinter import * from tkinter import messagebox, filedialog import pyttsx3 import PyPDF2 import os import webbrowser root = Tk() # root.geometry("500x500") root.title("Audio Book") speaker = pyttsx3.init() # speaker volume volume = Label(root, text="Volume", width=25) volume.grid(row=1, column=0) volumeSlider = Scale(root, from_=0.1, to=10, orient=HORIZONTAL, width=25) volumeSlider.set(0.7) volumeSlider.grid(row=1, column=1) # speaker volume rate speakerRate = Label(root, text="Speaker Rate", width=25) speakerRate.grid(row=2, column=0) speakerRateSlider = Scale(root, from_=100, to=400, orient=HORIZONTAL, width=25) speakerRateSlider.set(100) speakerRateSlider.grid(row=2, column=1) btnStart = Button(root, text="Start reading", state=DISABLED, width=25, fg="#787878") btnStart.grid(row=6, column=0, columnspan=2, pady=5) def selectBook(): global book global page global text global pdfReader global pages global selectPage global filepath try: filepath = filedialog.askopenfilename(initialdir="", title="Select a pdf book", filetypes=(("pdf files", ".pdf"), ("all_files", "*.*"))) # book name bookName = os.path.basename(filepath) bookNameLabel = Label(root, text="Name : "+bookName).grid(row=0,column=0, columnspan=2) # open,read get page number of book book = open(filepath, 'rb') pdfReader = PyPDF2.PdfFileReader(book) pages = pdfReader.numPages # select page label selectPageLabel = Label(root, text="Page ", width=25).grid(row=4, column=0) # select page slider selectPage = Scale(root, from_=1, to=pages, orient=HORIZONTAL) selectPage.grid(row=4, column=1) # button start btnStart = Button(root, text="Start reading", command=read, width=25, bg="#47fff7", fg="#787878").grid(row=6, column=0, columnspan=2, pady=5) except: print("You didn't select any file") def read(): # opening browser webbrowser.open_new(filepath) page = pdfReader.getPage(selectPage.get() - 1) text = page.extractText() print(pages) volume = volumeSlider.get() speakerRate = speakerRateSlider.get() speaker.setProperty("rate", speakerRate) speaker.setProperty('volume', volume) speaker.say(text) speaker.runAndWait() selectBook = Button(root, text="Choose a book", command=selectBook, width=25, bg="#307fff", fg="#b3b3b3") selectBook.grid(row=3, column=0, columnspan=2, pady=5) root.mainloop() ``` Error : ```plain Traceback (most recent call last): File "/home/istiak/PycharmProjects/Pandas/main.py", line 12, in <module> speaker = pyttsx3.init() File "/home/istiak/PycharmProjects/Pandas/venv/lib/python3.9/site-packages/pyttsx3/__init__.py", line 22, in init eng = Engine(driverName, debug) File "/home/istiak/PycharmProjects/Pandas/venv/lib/python3.9/site-packages/pyttsx3/engine.py", line 30, in __init__ self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File "/home/istiak/PycharmProjects/Pandas/venv/lib/python3.9/site-packages/pyttsx3/driver.py", line 50, in __init__ self._module = importlib.import_module(name) File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/home/istiak/PycharmProjects/Pandas/venv/lib/python3.9/site-packages/pyttsx3/drivers/espeak.py", line 9, in <module> from . import _espeak, toUtf8, fromUtf8 File "/home/istiak/PycharmProjects/Pandas/venv/lib/python3.9/site-packages/pyttsx3/drivers/_espeak.py", line 18, in <module> dll = cdll.LoadLibrary('libespeak.so.1') File "/usr/lib/python3.9/ctypes/__init__.py", line 452, in LoadLibrary return self._dlltype(name) File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) OSError: libespeak.so.1: cannot open shared object file: No such file or directory ``` I am using Manjaro. I have found a related issue in [git issue](https://github.com/nateshmbhat/pyttsx3/issues/41). They said to install `libespeak1` and, `alsa-utils`. I have installed both of them even, I had installed pyttx, pyaudio using pip3. Although, I am facing the same issue. Why it's happening?