Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add to F-Droid #520

Closed
Dmole opened this issue Jan 10, 2024 · 40 comments
Closed

Add to F-Droid #520

Dmole opened this issue Jan 10, 2024 · 40 comments

Comments

@Dmole
Copy link

Dmole commented Jan 10, 2024

https://f-droid.org/contribute/

@csukuangfj
Copy link
Collaborator

Are you going to contribute to add it?

@Dmole
Copy link
Author

Dmole commented Jan 10, 2024

I'll help if I can,

Step one is obtaining your (original app author) approval.
Step two is having you (someone familiar with the app) give the Inclusion Policy a quick read to see if any of the 12+ points are show stoppers.

Or if there is a conflict ( like https://github.com/edeso/bubble2 wanting to use unrar-nonfree vs unrar-free) the app can be added via an alternative repository (vs the main repository).

@csukuangfj
Copy link
Collaborator

give the Inclusion Policy a quick read to see if any of the 12+ points are show stoppers.

Could you tell us where we can find the above 12+ points?

@Dmole
Copy link
Author

Dmole commented Jan 13, 2024

From the link in the first post;

Submit Applications

If you see an application missing from the repository (after reading the inclusion policy ...

@csukuangfj
Copy link
Collaborator

Step one is obtaining your (original app author) approval.

We are very glad if you can contribute to add it to F-Droid as long as you state that the app is from this repo.

Step two is having you (someone familiar with the app) give the Inclusion Policy a quick read to see if any of the 12+ points are show stoppers.

I have just gone through all the items and I think we are not violating any of them.

@Dmole
Copy link
Author

Dmole commented Jan 14, 2024

https://gitlab.com/fdroid/rfp/-/issues/2629

@csukuangfj
Copy link
Collaborator

@paolo-caroni
Copy link
Contributor

This would be more difficult than a normal app, since each language and each voice are included on the apk package. It should be done as for AnySoftKeyboard for example. I have done the fastlane data for one app, but this probably would be more difficult. Also the icon should be improved, anyone know if there is a svg of the logo?

@csukuangfj
Copy link
Collaborator

For the logo, please have a look at
https://k2-fsa.github.io/k2/_images/logo.png

@csukuangfj
Copy link
Collaborator

since each language and each voice are included on the apk package.

The major issue is that we don't know how to download model files in Android.

If you can help, a better design is to download models for a certain language requested by the user.

@paolo-caroni
Copy link
Contributor

For the logo, please have a look at https://k2-fsa.github.io/k2/_images/logo.png

Ok, is still a png, but I can work on it, you are sure that is the correct one? on the official page I have found the other logo.

Also, about helping on improve the download capability, I'm sorry, I can do only hint of other open-source project that already did it.
I can help only on fastlane and logo.
Fastlane is very impiortant for F-Droid, since thank to it is all automatic wen the app is added for the first time, the F-Droid server search if there is a new release (that should be tagged on github) and then create the new apk automatically.

@csukuangfj
Copy link
Collaborator

on the official page I have found the other logo.

Sorry that I did not notice this page before.


next-gen-kaldi-logo.pdf

Please find all of the logos of next-gen kaldi in the above pdf, including the one for Sherpa.
(This is the first time we make the logo of Sherpa available to the public)

@paolo-caroni
Copy link
Contributor

Thanks, the logo seems to be too detailed in my honest opinion. Don't misunderstood, is beautiful, but will be difficult make it an adaptive icon. In the next weeks I will do my best and then ask a pr, but please dont expect too much, especially on the monochrome icon(maybe if looks to ugly I will drop it).

@gabmert
Copy link

gabmert commented Aug 23, 2024

Thanks for this great work! If publishing to f-droid.org isn't feasible right now, maybe you could set up your own repo in the meantime? This would result in automatic updates.
I hope it's just a simple http server https://f-droid.org/docs/Setup_an_F-Droid_App_Repo/
Someone even automated it with github actions https://github.com/xarantolus/fdroid/blob/main/setup.md

@linsui
Copy link

linsui commented Jan 2, 2025

I can help package this app. I tried to package sherpa-ncnn but it seems it's not maintained anymore. Which app should we package? There are lots of apks listed in the readme.

@csukuangfj
Copy link
Collaborator

sherpa-ncnn is developed and maintained by us.

Do you have any issues with sherpa-ncnn?

@linsui
Copy link

linsui commented Jan 2, 2025

Yes, as I said in k2-fsa/sherpa-ncnn#237, the version name and version code need to be bumped for every new version. And I need to add fastlane files in the repo.

@woheller69
Copy link

Maybe I can help publishing on F-Droid. I already have 20 apps there.
Some of them are also AI based like whoBIRD, Seamless, and Whisper.
They download the models (.tflite, .ptl) from GitHub or Hugging Face with a built-in downloader.
(e.g. https://github.com/woheller69/seamless/blob/master/app/src/main/java/com/seamless/utils/Downloader.java)
Of course this needs internet permission but the apps are open source and F-Droid checks which URLs are being called by the app.
The app size with built-in models would just be to big if we want to have TTS Engines for many languages on F-Droid.
I tried to build the tts engine from this project but I have no clue how it works.
For F-Droid everything needs to be built from source or come from a trusted party like Maven.
So the Android libraries should be available on Maven to keep things simple.
I found a lib there, but I am not sure if that is the right one.

https://mvnrepository.com/artifact/com.bihe0832.android/lib-sherpa-onnx/6.22.3

With such a library we can simply add it to build gradle and do not need to load the library later.

 implementation 'com.bihe0832.android:lib-sherpa-onnx:6.22.3'

The model should not be placed in "assets" folder but be downloaded later and placed in

sdcardDataFolder = this.getExternalFilesDir(null);

In older Android versions it is also possible to put files there "manually". (Android/data/com.k2fsa.sherpa.onnx.tts.engine/ files ...)

In order to keep it simple we should probably have the relevant code just for the tts engine in a separate repo and not in a huge repo like this with some files just being symlinks to other folders etc.
Maybe someone can show how to would build the tts engine e.g. for Piper voice Thorsten medium if placed in sdcardDataFolder.
Unfortunately I am not an expert in Kotlin, most of my code is Java...

Maybe someone can help getting this done :-)

@paolo-caroni
Copy link
Contributor

@woheller69 please watch this fork https://github.com/jing332/SherpaOnnxTtsEngineAndroid and also read the issue #569

@woheller69
Copy link

I downloaded and installed it, but it did not work. No commit for 11 months, so it seems unmaintained.

Are all these precompiled libraries needed?

Image
For F-Droid they would all need to be built from source or available from Maven.

@woheller69
Copy link

woheller69 commented Jan 28, 2025

I managed to build it using pre-built libraries from https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.10.41/sherpa-onnx-v1.10.41-android.tar.bz2 (just libonnxruntime.so and libsherpa-onnx-jni.so)

I used German voice Piper Thorsten Medium.

It seems the app only copies espeak-ng-data folder to external directory and keeps the onnx model and tokens.txt in assets.
If I copy all data to external directory (Android/data/com.k2fsa.sherpa.onnx.tts.engine/files, remove the asset files and force

newFromFile(config)

instead of

newFromAsset(assetManager, config)

in Tts.kt the app crashes and says it does not find the model.
Any ideas how that can be fixed? Having the model(s) in assets in not possible if we want to keep app size in an acceptable range.
EDIT: I found it :-)

My project is here: https://github.com/woheller69/ttsEngine

BTW, I think there are a few wrong tokens in Thorsten voice:
woheller69/ttsEngine@5a896d0

@csukuangfj
Copy link
Collaborator

in Tts.kt the app crashes and says it does not find the model.

Please post the complete logs.


Having the model(s) in assets in not possible if we want to keep app size in an acceptable range.

We indeed support not using model files from assets.

@woheller69
Copy link

woheller69 commented Jan 28, 2025

I managed to load the model from external directory, everything works fine.

But the problem is now that I somehow crashed my settings for TTS as reported in #670.
No idea what is wrong. Even if I uninstall all TTS apps I cannot even use Google TTS anymore after reinstallation...
Probably an issue of LineageOS on that device.
(EDIT: Fix with : adb shell settings put secure "tts_default_synth" com.google.android.tts)

Other than that everything works fine. No problem on other devices.
At the moment we can download German, English, Spanish, French, and Portuguese

https://github.com/woheller69/ttsEngine

@woheller69
Copy link

In order to publish on F-Droid we need to automatically build the libraries and move them to the jniLibs folder.
Maybe @linsui can help with a build script for F-Droid.

At the moment my code works for the above 5 languages. Other languages can be used if model.onnx and tokens.txt are copied to
Android/data/org.woheller69.ttsengine/files/modelDir, e.g. via adb, or depending on Android version with a file manager.
In addition a file called "lang" needs to be created which contains the language code, e.g. "eng".
It should work with the Piper voices from

https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models

@woheller69
Copy link

For onnx download I also tried the onnx from here, but it did not work.

https://huggingface.co/rhasspy/piper-voices/tree/main/de/de_DE/thorsten/medium

Do your onnx files differ from the "original" from piper-voices?

@csukuangfj
Copy link
Collaborator

yes, we add meta data to them.

Make sure you do read our doc for how to add meta data to piper models.

We have documented it clearly.

@woheller69
Copy link

Ok, no problem. I am using your models from Hugging Face. Just wanted to understand why the other models do not work.

@woheller69
Copy link

I think publishing on F-Droid will be hard. During the build process of libsherpa-onnx-jni.so a lot of stuff is downloaded
including libonnxruntime.so and other stuff. For F-Droid everything needs to be built from source or included from Maven.

In my code I removed libonnxruntime.so from jniLibs and included it from Maven instead via
implementation("com.microsoft.onnxruntime:onnxruntime-android:1.17.1")

If this could also be achieved for libsherpa-onnx-jni.so we could easily publish it. But that is nothing I can do...

@csukuangfj
Copy link
Collaborator

We do provide Android maven package for sherpa-onnx.

Please see.SherpaOnnxJavaDemo inside the android directory.

@woheller69
Copy link

Unfortunately it does not work if I add

    maven {
        setUrl("https://jitpack.io")
    }

and

implementation("com.github.k2-fsa:sherpa-onnx:v1.10.41")

I get this error:

Read binary file: Load /storage/emulated/0/Android/data/org.woheller69.ttsengine/files/modelDir/model.onnx failed

@woheller69
Copy link

Unfortunately it does not work. If I remove the .so files and add

    maven {
        setUrl("https://jitpack.io")
    }

and

implementation("com.github.k2-fsa:sherpa-onnx:v1.10.41")

I get this error:

Read binary file: Load /storage/emulated/0/Android/data/org.woheller69.ttsengine/files/modelDir/model.onnx failed

@woheller69
Copy link

is the library on Jitpack maybe compiled without TTS support?

@woheller69
Copy link

V1.1 now provides all Piper Voices for download:

https://github.com/woheller69/ttsEngine/releases/tag/V1.1

So the only thing needed would be a library from Jitpack / Maven which works...

@woheller69
Copy link

For whatever reason it worked with implementation("com.github.k2-fsa:sherpa-onnx:v1.10.41") when I tried again.
But only for a debug version.

When I try to build a release I get:

Type com.k2fsa.sherpa.onnx.GeneratedAudio is defined multiple times:

It seems the library contains the classes defined in Tts.kt. If I remove Tts.kt the app does not work anymore

@csukuangfj
Copy link
Collaborator

can you share error logs?

@csukuangfj
Copy link
Collaborator

By the way, errors related to model.onnx have nothing to do with the provided maven package.

Also, the package contains both shared libraries AND Kotlin files. You don't need to add Tts.kt.

Note that we have already had a working example using the maven package. If you.have any errors about the usage, please first debug it by yourself. It is very likely that you make mistakes somewhere.

@woheller69
Copy link

Thanks for the hint. I had one hardcoded change in my Tts.kt to load the model from files instead of loading from assets.
When I removed my Tts.kt the app tried to load the model from assets again. So I needed to pass "null" instead of "assets" when creating OfflineTts:

tts = OfflineTts(assetManager = null, config = config)

Working now :-)

@woheller69
Copy link

Merge request created on F-Droid

https://gitlab.com/fdroid/fdroiddata/-/merge_requests/19142

@woheller69
Copy link

This issue can be closed. App is merged in F-Droid and will be available in a few days.

@csukuangfj
Copy link
Collaborator

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants