piper icon indicating copy to clipboard operation
piper copied to clipboard

Issue downloading Piper due to dependancies?

Open SlayBrother opened this issue 8 months ago • 11 comments

Hey friends, I have never touched Piper before and I went to download it and right away i'm having immediate issues. Does anybody know why this would be happening or have a work around?

Image

SlayBrother avatar Jun 25 '25 18:06 SlayBrother

For a workaround, see either this: https://github.com/rhasspy/piper-phonemize/issues/33#issuecomment-2540407032 or this: https://github.com/rhasspy/piper/issues/217#issuecomment-2599240782

rkrisztian avatar Jun 28 '25 22:06 rkrisztian

If you're still looking to fix this, you can try pip install piper-phonemize-fix

I was running into the same issue and found this https://pypi.org/project/piper-phonemize-fix/

Everything seems to work now.

DexLuther avatar Jul 03 '25 03:07 DexLuther

Re: https://github.com/rhasspy/piper/issues/814#issuecomment-3030455246

It theoretically installs on Termux:

  1. pip download piper-phonemize-fix (sic)
  2. Untar it
  3. git clone https://github.com/espeak-ng/espeak-ng and install for the .h header files.
  4. Make piper-phonemize-fix use 3 via some cmake changes mostly.
  5. Install thus piper-phonemize with 'inbuilt' onxxruntime (takes some 15 minutes)
  6. pip install piper-tts --no-deps without a hitch (cause: piper-tts 1.2.0 depends on piper-phonemize~=1.1.0)
  7. Discover that the wrong glibc only version of onnruxtime was still pulled and compiled:
piper                 Traceback (most recent call last):                              File "/data/data/com.termux/files/usr/bin/piper", line 5, in <module>                                                         from piper.__main__ import main                             File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/piper/__init__.py", line 1, in <module>                    from .voice import PiperVoice                               File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/piper/voice.py", line 10, in <module>                      from piper_phonemize import phonemize_codepoints, phonemize_espeak, tashkeel_run                                          File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/piper_phonemize/__init__.py", line 13, in <module>         from piper_phonemize_cpp import (                         ImportError: dlopen failed: library "libdl.so.2" not found: needed by /data/data/com.termux/files/usr/lib/python3.12/site-packages/piper_phonemize/lib/libonnxruntime.so.1.14.1 in namespace (default)

So one needs also: 0. Pip install and compile onnruxtime itself to make it Bionic friendly, which can be done (because see apt list | grep onnxruntime for starters), but, hm, it takes skill: the series of patches, switches and further git clones of the missing bits in Termux would be much too long to list here.

Manamama avatar Jul 07 '25 23:07 Manamama

Oh, I have installed it somehow with regular piper-phonemize. Not sure how, as Gemini CLI re-re-fixed and installed it, so I am just attaching the resulting Gemini's gems of wisdom about her fixes, with minute updates of mine: '

Compilation and Test Fixes for piper-phonemize

This document outlines the issues encountered during the compilation and testing of the piper-phonemize project, along with the solutions implemented.

0. Copy onnxruntime dependencies

A. git clone https://github.com/microsoft/onnxruntime itself, e.g. to : ~/downloads/onnxruntime/, but do not install it (as you shall likely fail to do so). B. apt install python-onnxruntime to get the Bionic .so files for onnxruntime. If not there, just use the attached: libonnxruntime.zip libonnxruntime.zip (I am not sure by now how I arrived at having it there, some ♊ Gemini magic maybe, but it is Bionic version thereof, indeed) C. ln -s /data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so /data/data/com.termux/files/usr/lib/libonnxruntime.so , ln -s /data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so.1 /data/data/com.termux/files/usr/lib/libonnxruntime.so.1, to create links to the Bionic .so file installed by B. (apt):

file /data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so.1.22.0
/data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so.1.22.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=765d9b181096947cf647218ab01461e121685992, stripped

D. cp ~/downloads/onnxruntime/include/onnxruntime/core/session/* /data/data/com.termux/files/usr/include/

1. Ambiguous sample Reference in speechWaveGenerator.cpp

Problem: The compiler reported an ambiguous reference to sample in src/speechPlayer/src/speechWaveGenerator.cpp. This was due to a conflict between a local typedef short sampleVal; typedef struct { sampleVal value; } sample; in sample.h and std::sample from the C++ standard library, exacerbated by using namespace std; in speechWaveGenerator.cpp.

Solution: To resolve the ambiguity, using namespace std; was removed from src/speechPlayer/src/speechWaveGenerator.cpp. All standard library functions (e.g., sin, fmod, exp, cos) were then explicitly qualified with std:: (e.g., std::sin). This ensured that the local sample type was correctly identified.

(Or use my old trick: https://github.com/rhasspy/piper/issues/525)

2. Missing onnxruntime_cxx_api.h and Incomplete ONNXRUNTIME_DIR

Problem: During compilation, the onnxruntime_cxx_api.h header file could not be found, leading to a fatal error. Investigation revealed that the ONNXRUNTIME_DIR CMake variable was resolving to an incomplete path (e.g., missing the version number). This was traced back to ONNXRUNTIME_VERSION not being consistently defined before ONNXRUNTIME_PREFIX was constructed, especially when the ONNX Runtime directory already existed.

Solution: The set(ONNXRUNTIME_VERSION "1.14.1") command was moved to the very top of CMakeLists.txt to ensure it is always defined before any other ONNX Runtime-related variables are used. Additionally, the conditional definition of ONNXRUNTIME_VERSION within the if(NOT DEFINED ONNXRUNTIME_DIR) block was removed, and the ONNXRUNTIME_PREFIX and ONNXRUNTIME_EXT definitions were moved outside this conditional block to ensure they are always set correctly.

3. "Unsupported Architecture" Error

Problem: After addressing the ONNX Runtime pathing, a new error "Unsupported architecture for onnxruntime" appeared. Debugging revealed that the CMAKE_SYSTEM_PROCESSOR variable was empty, preventing CMake from correctly identifying the target architecture (aarch64 for Termux on Android).

Solution: The CMAKE_SYSTEM_PROCESSOR variable was explicitly set to aarch64 in CMakeLists.txt using set(CMAKE_SYSTEM_PROCESSOR "aarch64"). This provided CMake with the necessary architecture information to proceed with the build.

4. espeak_TextToPhonemesWithTerminator Symbol Not Found During Testing

Problem: Although the project compiled successfully, the test_piper_phonemize executable failed to link at runtime with a "cannot locate symbol espeak_TextToPhonemesWithTerminator" error. This indicated that the dynamic linker could not find the espeak-ng library at runtime, despite it being correctly linked during compilation.

Solution: The Makefile's ctest command was modified to include the LD_LIBRARY_PATH environment variable. This variable was set to include the paths to the espeak-ng and onnxruntime libraries within the build directory ($(CURDIR)/build/ei/lib:$(CURDIR)/build/lib). This ensured that the dynamic linker could locate the necessary shared libraries when running the tests.

These fixes collectively resolved the compilation and testing issues, allowing the piper-phonemize project to build and pass its tests successfully. '

Proof:

~/downloads/piper-phonemize $ uname -a
Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android
~/downloads/piper-phonemize $ piper                           usage: piper [-h] -m MODEL [-c CONFIG] [-f OUTPUT_FILE]
             [-d OUTPUT_DIR] [--output-raw] [-s SPEAKER]                   [--length-scale LENGTH_SCALE]
             [--noise-scale NOISE_SCALE] [--noise-w NOISE_W]               [--cuda] [--sentence-silence SENTENCE_SILENCE]
             [--data-dir DATA_DIR]                                         [--download-dir DOWNLOAD_DIR] [--update-voices]
             [--debug]
piper: error: the following arguments are required: -m/--model~/downloads/piper-phonemize $

, it does not kvetch about onnxruntime anymore and ctests also were passed (by Gemini).

Update: Gemini also packed it as .whl. Caveat emptor, "it works on my (Termux, non-glibc) end", etc.

Update: also the voices data is soft coded by default. I will let Gemini speak, too, sorry for the length, am on mobile, so no tome to make it shorter:


Using Downloaded Piper Voice Files

Problem: After downloading voice .onnx and .onnx.json files, the piper executable failed to synthesize audio, reporting that it could not find espeak-ng-data in its default system location (/usr/share/espeak-ng-data).

Solution: The ESPEAK_DATA_PATH environment variable was used to explicitly point the piper executable to the correct location of the espeak-ng-data directory, which was installed as part of the espeak-ng-external build.

The voice files (en_US-lessac-medium.onnx and en_US-lessac-medium.onnx.json) were downloaded to the project root:

  • https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx
  • https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json

To synthesize audio, the piper command was executed with ESPEAK_DATA_PATH set:

ESPEAK_DATA_PATH=/data/data/com.termux/files/home/downloads/piper-phonemize/build/ei/share/espeak-ng-data \
/data/data/com.termux/files/usr/bin/piper --model en_US-lessac-medium.onnx --output_file welcome.wav

These fixes collectively resolved the compilation and testing issues, allowing the piper-phonemize project to build, pass its tests, and successfully synthesize audio using downloaded voice models.


ver. 1.6, spelling fixes, espeak data location trick added, onnxruntime tricks added, together with libonnxruntime.zip itself just in case, as they are needed after all (tested on new virgin Droid).

piper_phonemize-1.2.0_by_Gemini-CLI_and_Manama_here_be_dragons.1.1-cp312-cp312-linux_aarch64.zip

Manamama avatar Jul 07 '25 23:07 Manamama

And for the record, final IRL test, sorry for formatting but spacing or EOLs play up upon paste:

~/downloads/piper-phonemize $ echo "Hello, this is a test." | piper -m en_US-lessac-medium.onnx -c en_US-lessac-medium.onnx.json  --output_file welcome.wav                               ~/downloads/piper-phonemize $ mediainfo welcome.wav           General                                                       Complete name                            : welcome.wav        Format                                   : Wave               Format settings                          : PcmWaveformat      File size                                : 66.5 KiB           Duration                                 : 1 s 544 ms         Overall bit rate mode                    : Constant           Overall bit rate                         : 353 kb/s                                                                         Audio                                                         Format                                   : PCM                Format settings                          : Little / Signed    Codec ID                                 : 1                  Duration                                 : 1 s 544 ms         Bit rate mode                            : Constant           Bit rate                                 : 352.8 kb/s         Channel(s)                               : 1 channel          Sampling rate                            : 22.05 kHz          Bit depth                                : 16 bits            Stream size                              : 66.5 KiB (100%)                                                                                                                                ~/downloads/piper-phonemize $ play welcome.wav                                                                              welcome.wav:                                                                                                                 File Size: 68.1k     Bit Rate: 353k                            Encoding: Signed PCM                                          Channels: 1 @ 16-bit                                        Samplerate: 22050Hz                                           Replaygain: off                                                 Duration: 00:00:01.54                                                                                                     In:0.00% 00:00:00.00 [00:00:01.54] Out:0     [      |      ]  In:24.1% 00:00:00.37 [00:00:01.17] Out:8.19k [!=====|=====!] HIn:48.1% 00:00:00.74 [00:00:00.80] Out:16.4k [!=====|=====!] HIn:72.2% 00:00:01.11 [00:00:00.43] Out:24.6k [-=====|=====-] HIn:96.2% 00:00:01.49 [00:00:00.06] Out:32.8k [ =====|===== ] HIn:100%  00:00:01.54 [00:00:00.00] Out:34.0k [      |      ] Hd:0.0 Clip:0                                                  Done.                                                         ~/downloads/piper-phonemize $

on:

~/downloads/piper-phonemize $ neofetch                                                                                      ------                                                        Operating System: Android 11 aarch64                          Kernel: 4.14.186+                                             Shell: /data/data/com.termux/files/usr/bin/bash 5.2.37        Python: 3.12.11

Manamama avatar Jul 08 '25 00:07 Manamama

Update: Plus a nice wrapper 🌯:

piperme() {
    if [ -z "$1" ]; then
        echo "Error: Please provide text or use -f <file>."
        return 1
    fi
    if [ "$1" = "-f" ]; then
        if [ ! -f "$2" ]; then
            echo "Error: File '$2' not found."
            return 1
        fi
        time cat "$2" | piper -m ~/downloads/piper-phonemize/en_US-lessac-medium.onnx -c ~/downloads/piper-phonemize/en_US-lessac-medium.onnx.json --output-raw | play -t raw -r 22050 -e signed -b 16 -c 1 -
    else
        time echo "$1" | piper -m ~/downloads/piper-phonemize/en_US-lessac-medium.onnx -c ~/downloads/piper-phonemize/en_US-lessac-medium.onnx.json --output-raw | play -t raw -r 22050 -e signed -b 16 -c 1 -
    fi
}

Faster and more reliable and more fun than termux-tts-speak. 🐲

Update, after 24 hours: Works fine also on another virgin Android, I have tweaked up the instructions a bit. (They are not in full, but one should manage now, with some AI's help.).

Below an updated wrapper, which now can handle langs and more:

function piperme() {
    echo "piperme: Using piper TTS to voice text via sox. Version 1.9"

    local voice_model_dir="/data/data/com.termux/files/home/.cache/piper"
    local lang="en"           # default language
    local input_text=""
    local input_file=""
    # Voice base name
    local voice_base=""
    
   # Parse optional language flag
    if [[ "$1" == "-pl" ]]; then
        lang="pl"
        shift
    elif [[ "$1" == "-en" ]]; then
        lang="en"
        shift
    fi
    

    if [[ "$lang" == "pl" ]]; then
        voice_base="pl_PL-darkman-medium"
    else
        voice_base="en_US-libritts-high"
    fi
    # Audio output settings
    local output_format="raw"
    local output_flag="--output-raw"
    local sample_rate="22050"
    local encoding="signed"
    local bit_depth="16"
    local channels="1"
    local play_opts="-t $output_format -r $sample_rate -e $encoding -b $bit_depth -c $channels -"

 

    # Check input source: file or direct text
    local stdin_cmd=""
    if [[ "$1" == "-f" ]]; then
        shift
        if [[ -z "$1" ]]; then
            echo "Error: Missing filename after -f." >&2
            return 1
        fi
        if [[ ! -f "$1" ]]; then
            echo "Error: File '$1' not found." >&2
            return 1
        fi
        stdin_cmd="cat \"$1\""
    else
        if [[ -z "$1" ]]; then
            echo "Error: Please provide text or use -f <file>." >&2
            return 1
        fi
        input_text="$*"
        stdin_cmd="echo \"$input_text\""
    fi



    local model_ext=".onnx"
    local config_ext="$model_ext.json"
    local model_file="$voice_model_dir/$voice_base$model_ext"
    local config_file="$voice_model_dir/$voice_base$config_ext"

    # Verify model files
    if [[ ! -f "$model_file" ]] || [[ ! -f "$config_file" ]]; then
        echo "Error: Voice model files for language '$lang' missing." >&2
        return 1
    fi

    # Common pipeline
    local piper_cmd="piper -m \"$model_file\" -c \"$config_file\" $output_flag | play $play_opts"

    # Run: XOR input, same pipe
    time eval "$stdin_cmd | $piper_cmd"
}

Ver. 1.9

Manamama avatar Jul 08 '25 02:07 Manamama

Oh, I have installed it somehow with regular piper-phonemize. Not sure how, as Gemini CLI re-re-fixed and installed it, so I am just attaching the resulting Gemini's gems of wisdom about her fixes, with minute updates of mine: '

Compilation and Test Fixes for piper-phonemize

This document outlines the issues encountered during the compilation and testing of the piper-phonemize project, along with the solutions implemented.

0. Copy onnxruntime dependencies

A. git clone https://github.com/microsoft/onnxruntime itself, e.g. to : ~/downloads/onnxruntime/, but do not install it (as you shall likely fail to do so). B. apt install python-onnxruntime to get the Bionic .so files for onnxruntime. If not there, just use the attached: libonnxruntime.zip libonnxruntime.zip (I am not sure by now how I arrived at having it there, some ♊ Gemini magic maybe, but it is Bionic version thereof, indeed) C. ln -s /data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so /data/data/com.termux/files/usr/lib/libonnxruntime.so , ln -s /data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so.1 /data/data/com.termux/files/usr/lib/libonnxruntime.so.1, to create links to the Bionic .so file installed by B. (apt):

file /data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so.1.22.0
/data/data/com.termux/files/usr/lib/python3.12/site-packages/onnxruntime/capi/libonnxruntime.so.1.22.0: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=765d9b181096947cf647218ab01461e121685992, stripped

D. cp ~/downloads/onnxruntime/include/onnxruntime/core/session/* /data/data/com.termux/files/usr/include/

1. Ambiguous sample Reference in speechWaveGenerator.cpp

Problem: The compiler reported an ambiguous reference to sample in src/speechPlayer/src/speechWaveGenerator.cpp. This was due to a conflict between a local typedef short sampleVal; typedef struct { sampleVal value; } sample; in sample.h and std::sample from the C++ standard library, exacerbated by using namespace std; in speechWaveGenerator.cpp.

Solution: To resolve the ambiguity, using namespace std; was removed from src/speechPlayer/src/speechWaveGenerator.cpp. All standard library functions (e.g., sin, fmod, exp, cos) were then explicitly qualified with std:: (e.g., std::sin). This ensured that the local sample type was correctly identified.

(Or use my old trick: #525)

2. Missing onnxruntime_cxx_api.h and Incomplete ONNXRUNTIME_DIR

Problem: During compilation, the onnxruntime_cxx_api.h header file could not be found, leading to a fatal error. Investigation revealed that the ONNXRUNTIME_DIR CMake variable was resolving to an incomplete path (e.g., missing the version number). This was traced back to ONNXRUNTIME_VERSION not being consistently defined before ONNXRUNTIME_PREFIX was constructed, especially when the ONNX Runtime directory already existed.

Solution: The set(ONNXRUNTIME_VERSION "1.14.1") command was moved to the very top of CMakeLists.txt to ensure it is always defined before any other ONNX Runtime-related variables are used. Additionally, the conditional definition of ONNXRUNTIME_VERSION within the if(NOT DEFINED ONNXRUNTIME_DIR) block was removed, and the ONNXRUNTIME_PREFIX and ONNXRUNTIME_EXT definitions were moved outside this conditional block to ensure they are always set correctly.

3. "Unsupported Architecture" Error

Problem: After addressing the ONNX Runtime pathing, a new error "Unsupported architecture for onnxruntime" appeared. Debugging revealed that the CMAKE_SYSTEM_PROCESSOR variable was empty, preventing CMake from correctly identifying the target architecture (aarch64 for Termux on Android).

Solution: The CMAKE_SYSTEM_PROCESSOR variable was explicitly set to aarch64 in CMakeLists.txt using set(CMAKE_SYSTEM_PROCESSOR "aarch64"). This provided CMake with the necessary architecture information to proceed with the build.

4. espeak_TextToPhonemesWithTerminator Symbol Not Found During Testing

Problem: Although the project compiled successfully, the test_piper_phonemize executable failed to link at runtime with a "cannot locate symbol espeak_TextToPhonemesWithTerminator" error. This indicated that the dynamic linker could not find the espeak-ng library at runtime, despite it being correctly linked during compilation.

Solution: The Makefile's ctest command was modified to include the LD_LIBRARY_PATH environment variable. This variable was set to include the paths to the espeak-ng and onnxruntime libraries within the build directory ($(CURDIR)/build/ei/lib:$(CURDIR)/build/lib). This ensured that the dynamic linker could locate the necessary shared libraries when running the tests.

These fixes collectively resolved the compilation and testing issues, allowing the piper-phonemize project to build and pass its tests successfully. '

Proof:

~/downloads/piper-phonemize $ uname -a
Linux localhost 4.14.186+ #1 SMP PREEMPT Thu Mar 17 16:28:22 CST 2022 aarch64 Android
~/downloads/piper-phonemize $ piper                           usage: piper [-h] -m MODEL [-c CONFIG] [-f OUTPUT_FILE]
             [-d OUTPUT_DIR] [--output-raw] [-s SPEAKER]                   [--length-scale LENGTH_SCALE]
             [--noise-scale NOISE_SCALE] [--noise-w NOISE_W]               [--cuda] [--sentence-silence SENTENCE_SILENCE]
             [--data-dir DATA_DIR]                                         [--download-dir DOWNLOAD_DIR] [--update-voices]
             [--debug]
piper: error: the following arguments are required: -m/--model~/downloads/piper-phonemize $

, it does not kvetch about onnxruntime anymore and ctests also were passed (by Gemini).

Update: Gemini also packed it as .whl. Caveat emptor, "it works on my (Termux, non-glibc) end", etc.

Update: also the voices data is soft coded by default. I will let Gemini speak, too, sorry for the length, am on mobile, so no tome to make it shorter:

Using Downloaded Piper Voice Files

Problem: After downloading voice .onnx and .onnx.json files, the piper executable failed to synthesize audio, reporting that it could not find espeak-ng-data in its default system location (/usr/share/espeak-ng-data).

Solution: The ESPEAK_DATA_PATH environment variable was used to explicitly point the piper executable to the correct location of the espeak-ng-data directory, which was installed as part of the espeak-ng-external build.

The voice files (en_US-lessac-medium.onnx and en_US-lessac-medium.onnx.json) were downloaded to the project root:

  • https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx
  • https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/en/en_US/lessac/medium/en_US-lessac-medium.onnx.json

To synthesize audio, the piper command was executed with ESPEAK_DATA_PATH set:

ESPEAK_DATA_PATH=/data/data/com.termux/files/home/downloads/piper-phonemize/build/ei/share/espeak-ng-data
/data/data/com.termux/files/usr/bin/piper --model en_US-lessac-medium.onnx --output_file welcome.wav These fixes collectively resolved the compilation and testing issues, allowing the piper-phonemize project to build, pass its tests, and successfully synthesize audio using downloaded voice models.

ver. 1.6, spelling fixes, espeak data location trick added, onnxruntime tricks added, together with libonnxruntime.zip itself just in case, as they are needed after all (tested on new virgin Droid).

piper_phonemize-1.2.0_by_Gemini-CLI_and_Manama_here_be_dragons.1.1-cp312-cp312-linux_aarch64.zip

If you could prepare a ready-to-use BOINC package, that would be great. The steps are quite confusing. Thank you for your good efforts.

gyroing avatar Jul 09 '25 06:07 gyroing

Re: https://github.com/rhasspy/piper/issues/814#issuecomment-3051394673, I could, but then, "me no programmer". It is only the second device (virgin Droid this time) that I made it work on and I do not need that much to install it in more non-glibc boxes 📦). I am mostly testing if a version of my PMBOK thinking template (aka methodology) https://github.com/google-gemini/gemini-cli/discussions/2386#discussion-8506860 works not only on "leetcode" puzzles 🧩 like there, but also on IRL convoluted more amorphous IT problems like this one. (As I wrote there, this time, late at 🌃, I even did not switch any such PM scaffolding, as somehow Gemini ♊ finally figured it on its own). It works fine by now: I guess one may feed the solution to another AI and have it properly recreated, with edge cases etc. (My two Droids 📲📱 are same model, just one was kept "virgin", almost default Termux, for such tests).

As a 🎁, I shall only further update https://github.com/rhasspy/piper/issues/814#issuecomment-3047131452, as I have just needed to use en_US-libritts-high instead there, so ChatGPT this time has just also taught me what "DRY", "hoisting", "Functional Composition" and "Modular Programming" are, as terms. (Myself I would call this structure and idea: "nested Matryoshka 🪆 atomic clockwork ⏰" for that matter... - the very names that I would use may also show you that I am not IT 🏋🏽‍♂️💼). For me, it all shows me that a non IT persona (moi), with two 🤞🏽s, on 🤳🏽, as a hobby almost (like also now typing this), can solve a thing or two. That is, to be precise: it shows that CLI based AIs can solve these, if given the right tools and solving plus ideation frameworks plus a rightly thinking human 💃🏽🕺🏽 User to boot. (Many folks I know are highly dismissive of all of these, as we know: https://github.com/google-gemini/gemini-cli/discussions/3316, etc ...)

Manamama avatar Jul 09 '25 09:07 Manamama

BTW, below is fully written by AI. Not Gemini this time but : https://askdev.ai/github/rhasspy/piper one, which I also start to love 💕. I had built it at least twice (over a year ago and now, twice in a row) in a slightly more convoluted way, and below does not work with e.g. the onxxruntime compile stage, but the general idea and tips are aligned with my method mostly, so for what is worth, my control paste:

' Here’s an end-to-end recipe for building Piper natively in Termux (arm64-Android/Bionic) without resorting to any glibc-based proot or container. In a nutshell you will:

  1. Install Termux SDK & native toolchain
  2. Grab or build a “C” inference library (ONNX-Runtime or TFLite) for Android/arm64
  3. Clone Piper and point Cargo at your Android libs
  4. Cargo-build Piper’s CLI in release mode

  1. Update Termux and install the Rust + C toolchain
pkg update && pkg upgrade -y
# core build tools:
pkg install -y \
  git \
  rust \
  clang \
  cmake \
  ninja \
  pkg-config \
  openssl \
  libsndfile \
  fftw \
  unzip
# Android NDK sysroot (for cross-x compiling inference engines)
pkg install -y ndk-sysroot
  1. Choose & prepare your inference engine
    Piper supports two “backends”: ONNX-Runtime (via the onnxruntime-sys crate) or TFLite (via tensorflow-lite-sys).

• ONNX-Runtime

  1. Clone ONNX-Runtime and build for Android/arm64
    git clone https://github.com/microsoft/onnxruntime.git
    cd onnxruntime
    ./build.sh \
      --config Release \
      --build_shared_lib OFF \
      --use_android_nnapi OFF \
      --android \
      --android_abi arm64-v8a \
      --android_ndk $PREFIX/opt/ndk-sysroot \
      --cmake_extra_defines CMAKE_INSTALL_PREFIX=$HOME/onnx-android
    make -j$(nproc) && make install
    

{Nota bene, wrong syntax, see Onxxruntime itself, Android section, and iterate these switches instead}

  1. After this you should have
    $HOME/onnx-android/lib/libonnxruntime.a
    $HOME/onnx-android/include/onnxruntime_c_api.h
    
  2. Export Cargo hooks so Piper’s build can see them
    export ONNXRUNTIME_LIBRARY_PATH=$HOME/onnx-android/lib
    export ONNXRUNTIME_INCLUDE_DIR=$HOME/onnx-android/include
    

• TensorFlow-Lite

  1. Download the official Android AAR (or C-API) from TensorFlow’s releases page:
    https://www.tensorflow.org/lite/guide
  2. Unzip to e.g. $HOME/tflite-android and note the libtensorflowlite_c.so or .a plus headers.
  3. Export:
    export TFLITE_LIBRARY_PATH=$HOME/tflite-android/lib
    export TFLITE_INCLUDE_DIR=$HOME/tflite-android/include
    
  1. Clone Piper and pick your backend
cd $HOME
git clone https://github.com/rhasspy/piper.git
cd piper
  1. Build the CLI
    Pick only one backend. If you built ONNX-Runtime, do:
cargo install --path . --locked --force \
  --no-default-features \
  --features onnxruntime

If you prefer TFLite:

cargo install --path . --locked --force \
  --no-default-features \
  --features tflite

What you’ve done here is disable Piper’s “default” feature set (which tries to link to desktop glibc libs) and instead enable only the Android-compatible backend you provided.

  1. Verify
which piper
piper --help
# try a quick synthesis
piper tts --model en-us-arctic-low --text "hello from termux"

That’s it — you now have a fully native Piper binary running on Termux, linked against Android’s bionic, using either ONNX-Runtime or TensorFlow-Lite under the hood.

'

Source: https://askdev.ai/github/rhasspy/piper

Manamama avatar Jul 09 '25 23:07 Manamama

Please try upgrading to piper 1.3.0 which is being developed here: https://github.com/OHF-Voice/piper1-gpl

synesthesiam avatar Jul 15 '25 16:07 synesthesiam

Yay, that simplifies a lot too: Allow text from one or more files with --input-file <FILE>, apart from getting rid of these Baroque C++ dependencies, as I can quickly see fromthe release notes... About to test it on my backup Droid soon

Manamama avatar Jul 15 '25 17:07 Manamama