piper-phonemize
piper-phonemize copied to clipboard
[Linux] Add Python 3.12 support
Hey! I was trying to pip install piper-tts, but it fails to resolve piper-phonemize. I see on PyPI that there is a Python 3.12 build for Mac OS, but not for Linux. As Python 3.12 is now the default on Arch Linux and Ubuntu 24.04 LTS, would it be possible to update or rebuild the package with support for 3.12?
Thanks, Pat
In the meantime, you can download the source from tag v1.1.0, and in it, edit the dockerfile to build a wheel for Python 3.12 (i.e., add to or replace the pip wheel calls to target cp312 rather than 311, 310...). The manylinux_2_28_x86_64 Docker image ships with CPython 3.12 so this is the only required change. Then you build per the readme file.
Then you install the whl you just built alongside with piper-tts. In pipx, you'd have to use something like --pip-args="$HOME/Temporary/piper-phonemize-1.1.0/dist/piper_phonemize-1.1.0-cp312-cp312-manylinux_2_28_x86_64.whl" (with an absolute path because pipx changes its working directory).
If you trust me—which you shouldn't since I could very well have added a system("rm -rf /home") or worse in there for kicks and giggles—here's my build: https://temp.zetanor.com/g417y32tss0q8l43bg4e6q/piper_phonemize-1.1.0-cp312-cp312-manylinux_2_28_x86_64.whl
In the meantime
Thanks. I decided it wasn't a high priority for me after all. I did want to test it locally real quick, but as I am already using Docker for a bunch of projects, I can easily run in an Ubuntu container with python 3.10.
Would it be possible to upload the source bundle to pypi? That would allow pip to build the wheel locally (assuming the needed packages are installed) rather than just having to wait for built wheels be be pushed to pypi
agreed
Checking in on this -
It's September, how's it going?
Does anyone interested working with me on that?
- Add option to build on Windows
- Add option to build on macOS
- Add
BUILDING.mdwith docs about build it on linux/macos/windows - Add CI on Github actions to build and publish pre built wheels for Windows/macOS.
Then we can create a PR here, and in the meantime a fork which will publish wheels.
Any progress? Upgraded to the Ubuntu LTS release and my home lost its voice. :/
I created pypy project search on my github
Maybe you can use the follow command to install the piper-phonemizer:
pip install piper_phonemize -f https://k2-fsa.github.io/icefall/piper_phonemize.html
I was able to get piper-tts installed on the latest Ubuntu LTS under python3.12 by (what I now realize is essentially @zetanor 's suggested method above) downloading an older version of the project from github and changing one line of the Dockerfile to compile a python 3.12 version. Here are the exact commands I issued in order (since it builds with docker, this should be fairly independent of your particular environ?). I did these as a regular user, not root. You will need to have docker-buildx installed and your user must be in the docker group:
-
git clone https://github.com/rhasspy/piper-phonemize.git -
cd piper-phonemize -
git checkout 20554f24f807146fcf183f4a22ac10e9f24c9f45 # Last checkin with 1.1.0 tag? -
vi Dockerfile # Add (it's obvious where): /opt/python/cp312-cp312/bin/pip wheel . && \ -
docker buildx build . -t piper-phonemize --output 'type=local,dest=dist' -
cd dist -
pip install piper_phonemize-1.1.0-cp312-cp312-manylinux_2_28_x86_64.whl -
pip install piper-tts
You can use this Dockerfile to build piper-phonemize for Python 3.12
- Replace the
Dockerfilein the repo with the one below - Run
docker buildx build . -t piper-phonemize --output 'type=local,dest=dist' - The
*.whlfile will be in thedist/
# For Python 3.9
#FROM debian:bullseye AS build
# For Python 3.11
# FROM debian:bookworm AS build
# For Python 3.12
FROM debian:trixie AS build
ARG TARGETARCH
ARG TARGETVARIANT
ENV LANG=C.UTF-8
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
build-essential cmake ca-certificates curl pkg-config git python3 python3-dev python3-pip
WORKDIR /build
COPY ./ ./
RUN cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install
RUN cmake --build build --config Release
RUN cmake --install build
# Do a test run
RUN ./build/piper_phonemize --help
# Build .tar.gz to keep symlinks
WORKDIR /dist
RUN mkdir -p piper_phonemize && \
cp -dR /build/install/* ./piper_phonemize/ && \
tar -czf "piper-phonemize_${TARGETARCH}${TARGETVARIANT}.tar.gz" piper_phonemize/
# Build Python wheel
ENV CPLUS_INCLUDE_PATH=/build/install/include
ENV LIBRARY_PATH=/build/install/lib
WORKDIR /build
RUN python3 -m pip install --upgrade pip setuptools wheel pybind11 --break-system-packages
RUN python3 setup.py sdist bdist_wheel
RUN cp dist/*.whl /dist/
# -----------------------------------------------------------------------------
FROM scratch
COPY --from=build /dist/piper-phonemize_*.tar.gz ./
COPY --from=build /dist/*.whl ./
I am new to this kind of stuff, including working in Linux, How do I build the file being described in this post:
https://github.com/rhasspy/piper-phonemize/issues/33#issuecomment-2540407032
?
Thank you in advance
@Baalduron See instructions above https://github.com/rhasspy/piper-phonemize/issues/33#issuecomment-2585318698
You will need Docker installed, see https://www.docker.com/get-started/ or Google how to install it. On Ubuntu sudo apt install docker-ce should install it.
Then clone this repo or download the code as zip and extract.
Then replace contents of Dockerfile in the repo code with the content from post above
Then Run docker buildx build . -t piper-phonemize --output 'type=local,dest=dist' from the folder containing repo code and the Dockerfile file.
The wheel file will be in dist folder
@raivisdejus thanks for your work,when i changed the dockerfile and run the docker build comand,every thing seemed ok.but the .wheel file is too small,about 171K,is that right?
i installed the wheel dependentlt,and test it in a script,but an error throwed as follow:
could you have a look at this? look for your reply.
First it seems that latest Debian Trixie is using Python 3.13 now, so to get 3.12 replace ~FROM debian:trixie AS build~ with FROM python:3.12.10-bookworm AS build
Second to fix the issue with libonnxruntime you would need to run pip install onnxruntime==1.14.1, but this will fail on python 3.12 and also python 3.11 as this version of onnxruntime only supports python 3.10
So IMO your best option is to use conda to create a virtual enviroment with python 3.10 https://www.anaconda.com/blog/getting-started-with-conda-environments
@raivisdejus here is my dockerfile mydockerfile.txt and follow is my build log build.log the whl file is still 182K,not as the same size as the repo released version.could you help chek where is wrong?for my personal guess,maybe the espeak-ng folder is not right in dockerfile pipline?and is not the fault of onnxruntime.look for your reply.thanks.