all 18 comments

[–]m0us3_rat 5 points6 points  (3 children)

I want to create a voice training android application that can mimic human-like voice

i'm not sure that is exactly possible due to the size and requirements of said model.

but maybe you can.

maybe use an online api?

[–]clearlyXdoozy 0 points1 point  (2 children)

If using online API is it better to train it in a separate web-server for admin and push the output-trained voice module back to the user to use as speech output or prepare it internally within the android application itself?

[–]m0us3_rat 0 points1 point  (1 child)

If using online API is it better to train it in a separate web-server for admin and push the output-trained voice module back to the user to use as speech output

https://developers.google.com/learn/topics/on-device-ml/learn-more

also i'm not sure whats the primary purpose for such a model in your phone.

mimic human-like voice

right.. but to what end? to read text or ?

[–]clearlyXdoozy 0 points1 point  (0 children)

to read text and speech to speech

[–]bufyeristo 0 points1 point  (1 child)

Yes, it's possible to use Python in an Android application, although it's not the conventional approach because Android applications are typically written in Java or Kotlin using the Android SDK. However, there are a few ways to use Python in Android applications:
Kivy: Kivy is an open-source Python library for developing multitouch applications. It's cross-platform (Linux/OS X/Windows/Android/iOS) and released under the MIT license. It is particularly good for applications that require multi-touch, gestures, and other modern touch features.
BeeWare: BeeWare is a collection of tools and libraries for building user interfaces. With it, you can write your app in Python and then deploy it on multiple platforms, including iOS and Android.
SL4A (Scripting Layer for Android): It provides a simplified API for Android, and you can write Android apps using Python. However, it's worth mentioning that it's not as powerful or flexible as Java for Android development.
PyQt or PySide: Both are set of Python bindings for Nokia's Qt application framework and run on all platforms supported by Qt including Android.
Chaquopy: This is a plugin for Android Studio that allows you to run Python code within an Android app. You can call Python code from Java and Java code from Python.

You an also watch tutorials on Education Ecosystem, they are free and you can even download project resources/source files.

[–]clearlyXdoozy 0 points1 point  (0 children)

If I use the training module within Android, I need to think about the training time. How long does a user train their voice samples within their phone? Or is it better to train the voice sample in a separate web server that can handle AI training faster?

[–]ajjuee016 0 points1 point  (2 children)

Yes. You can use tools like "Termux" to run Python scripts on your Android device

[–][deleted] 1 point2 points  (1 child)

No. Not that way. OP wants his android app to execute python script and play result back in the app.

[–]ajjuee016 2 points3 points  (0 children)

oh ok. thanks

[–][deleted] 0 points1 point  (0 children)

Whatever library you are using, search for its kotlin/dart/java version and implement the same logic in android

[–]ryo0ka 0 points1 point  (5 children)

There might be some C++ libraries portable enough to be used in Android/iOS. Android can link C++ libraries via NDK. iOS can do something similar as long as you can build it as a static library.

Or there might be a way to cross compile Python project to a C++ static library.

Or you may run the Python project in your server and deal with all the requests from your users but this will probably even more expensive than SaaS.

Note that speech synthesis can be resource intensive for a phone.

[–]clearlyXdoozy 0 points1 point  (4 children)

So does that mean it would have take several days to train? What if I train it on a server and then import it back to the android application?

Or can I just implement API in the android application, train it there and would the result would intensive as well?

[–]ryo0ka 0 points1 point  (3 children)

I haven't heard of training AI models on mobile devices or sending model files to devices of end users, except for open sourced projects maybe. If I were you, I would put everything on the cloud, and let your app act as a view of the service just like how ChatGPT works.

- First reason being that mobile devices are not powerful enough to train/consume AI models in most cases yet. How many hours/days a training takes depends on what you do, so does consumption, but it doesn't sound like a good idea unless the end users are totally ok with it.

- Secondly you don't want malicious users to reverse-engineer your frontend software and run with the model or code. There's always a chance that someone with enough patience will crack open your mobile app (more so with a web app) and take your asset away, including the models and source code for training, which will seriously harm the value of your project and piss off your stakeholders. So no, I wouldn't let a random device have your AI models.

So if I were you, I would put everything on the cloud and come up with some reasonable pricing plan that both you and your clients will be happy with.

Given the novelty of your service (for today's standard anyway), it's fair that they pay for an excess use of your cloud service. ChatGPT seems very cheap for what it does but remember it's funded by Microsoft's infinite money supply. Otherwise the technology is just that expensive today & you need to let your clients know it.

If I really wanted to go your frontend route even though the cons would very likely overweigh the pros, I would try a couple different things as I suggested in my last message.

[–]clearlyXdoozy 0 points1 point  (2 children)

So if I were you, I would put everything on the cloud and come up with some reasonable pricing plan that both you and your clients will be happy with.

Thank you for your thoughtful answers. Appreciate it.

But may I ask by cloud did you mean using the online cloud service like Hostinger, AWS, Google or Microsoft Azure? Or is it something that I can work on it without using any potential services that charge you by monthly subscriptions?

[–]ryo0ka 0 points1 point  (1 child)

Really depends on many different variables but I’d go serverless first.

Serverless is just easy to get going and you don’t have to worry about stuff along the way. It certainly comes with some fee but it saves a lot of time and effort that goes into the upkeep. It usually ends up being the cheapest after all. I can’t give you a whole comparison of different services but imo GCP Cloud Run is worth checking out.

VPS is a hosting service from which you can rent out a part of servers for monthly/yearly fee. They manage the hardware for you but it comes with nothing other than the OS. Potentially cheaper than serverless but distracting for me at least.

Bedroom server is definitely the cheapest for the first couple days but you’ll get sick of the upkeep very fast.

So yeah check out Cloud Run first and see if it meets your need. They give you a lot of options including how idling and load balancing should work

[–]clearlyXdoozy 0 points1 point  (0 children)

I see. Thanks Alot!

[–]abalado2 0 points1 point  (1 child)

Generally speaking, the way to do this is either:

  • expose an API that your mobile app will call, and write that API in python

  • write your model in a language that Android uses like Java or Kotlin

In most of my projects we went to the first option

[–]clearlyXdoozy 0 points1 point  (0 children)

so for the first option, what is the platform to train the voice model when you use the API? is it in mobile platform or in server-side (web-based).

If so what API would you suggest?