Espeak error in a discord bot

Hi, I am trying to make a text to speech feature to work in a discord python bot. I am using pyttsx3 library and is working locally but it does not when I deploy it to railway, I get the error: libespeak.so.1: cannot open shared object file: No such file or directory railway I have seen that is a common error when you don't have eSpeak installed. Is there a way I can install it into my app, I tried using a custom nixpack file to execute a apt-get install but it didn't work. I wanted to know if it is possible for me to do it. And if it is not, any mean that you may know as possible. Thanks in advance.
12 Replies
Percy
Percy2y ago
Project ID: N/A
luna
luna2y ago
youll probably need a custom dockerfile todo this since youll need to run an apt-get command to install the library. not sure if the nixpacks allow doing that.
Pastor
PastorOP2y ago
N/A Thanks, I will try that I tried with the custom dockerfile and it did install it but I guess this override the main docker configuration and the is not running, is there a way in which I can get how it is written (I mean de custom docker file)?
Brody
Brody2y ago
you should be able to do this with a nixpacks file
[phases.setup]
aptPkgs = ["...", "libespeak1"]
[phases.setup]
aptPkgs = ["...", "libespeak1"]
remove your dockerfile for now and use that as a nixpacks.toml file
Pastor
PastorOP2y ago
This is without a doubt the right way, it seems like the first time I tried with the nixpack file I broke something, but removing de custom Dockerfile and just writing that line that Brody commented is enough to install it (I see it in the build logs), but for some reason it stills gives me the same error. Is it possible that the next log line has anything to do with it? "debconf: delaying package configuration, since apt-utils is not installed"
Brody
Brody2y ago
can you share your repo?
Pastor
PastorOP2y ago
sure here it goes, https://github.com/PastorL/el_facha_tarkovsky_bot the nixpacks file has the "espeak" library instead of the "libespeak1" one because I already try with that one, and right now I'm just testing if anything goes
GitHub
GitHub - PastorL/el_facha_tarkovsky_bot: Bot de discord
Bot de discord. Contribute to PastorL/el_facha_tarkovsky_bot development by creating an account on GitHub.
Brody
Brody2y ago
try
[phases.setup]
aptPkgs = ["...", "libespeak-dev"]
[phases.setup]
aptPkgs = ["...", "libespeak-dev"]
Pastor
PastorOP2y ago
I tried, it keeps showing the same error, I will keep trying with different libraries to see if anything work
Brody
Brody2y ago
might have to move to a Dockerfile based build
Pastor
PastorOP2y ago
Well finally I manage to make it work so I'm going to leave here how I did it just in case in the future someone needs it. For installing espeak in the railway environment the best way was with the nixpacks file as Brody suggested. The problem was that once it was installed I got an error related to comtypes. COMTypes works only in windows is not made for Linux, it won't work in railway. So unfortunately it can't be done with pyttsx3 (which of all the open libraries that I tried, it has the best voice management). But I can be done just as easy with gtts and you can still manage voices and connections to voice channels, so I would recommend using this one instead. Thanks again for the help, I hope it helps and please feel free to close the ticket.
Brody
Brody2y ago
thank you for coming back and explaining how you solved it, much appreciated ❤️
Want results from more Discord servers?
Add your server