How can we implement Speech ToText tflite model in android studio?

How can we implement Speech ToText tflite model in android studio?

@It_Solution,

Welcome to the Tensorflow Forum!

We should convert Tensorflow/Keras model to tflite model using tf.lite.TFLiteConverter.

Later we can use tflite model in android studio using Quick Start guide for Android.

We can also check tflite examples using android here TensorFlow Lite Examples | Machine Learning Mobile Apps.

Thank you!

Implementing a Speech To Text TFLite model in Android Studio involves several steps:

  1. Download and import the TFLite model into your Android Studio project.
  2. Set up the input and output configurations of the TFLite model. This involves specifying the input data format (e.g., audio input) and output data format (e.g., text output).
  3. Initialize the TFLite interpreter and load the TFLite model into memory.
  4. Convert the audio input data into the input format required by the TFLite model. This may involve pre-processing steps such as feature extraction and normalization.
  5. Run the TFLite interpreter on the input data to generate the output text.
  6. Post-process the output text to correct any errors and format it for display.

Here are some general steps you can follow to implement a Speech To Text TFLite model in Android Studio:

  1. Create a new Android Studio project and add the TFLite model to the project’s assets folder.
  2. Add the TFLite Java API library to your project’s dependencies.
  3. Create a new activity for your Speech To Text app and set up the audio input.
  4. Initialize the TFLite interpreter and load the TFLite model into memory.
  5. Set up the input and output configurations of the TFLite model.
  6. Convert the audio input data into the input format required by the TFLite model.
  7. Run the TFLite interpreter on the input data to generate the output text.
  8. Post-process the output text to correct any errors and format it for display.
  9. Test your app on a physical device or emulator to ensure it is working correctly.

Note that the specifics of implementing a Speech To Text TFLite model in Android Studio will depend on the specific model you are using and the requirements of your app. It’s important to follow the documentation and guidelines provided by the model developer to ensure you are using the model correctly and effectively.

sir i have this source code its working fine on all devices but its not working in android 7 and 8 please fix the error for me i am student its my university project i don’t have more experience

On this line i get crash in android 7 only and 8

static {
System.loadLibrary(“native-lib”);
}

$ adb shell am start -n “com.whisper.android.tflitecpp/com.whisper.android.tflitecpp.MainActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 25507 on device ‘samsung-sm_g920k-192.168.100.62:5555’.
Capturing and displaying logcat messages from application. This behavior can be disabled in the “Logcat output” section of the “Debugger” settings page.
E/Zygote: v2
I/libpersona: KNOX_SDCARD checking this for 10209
I/libpersona: KNOX_SDCARD not a persona
E/Zygote: accessInfo : 0
W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0010, [-1 -1 -1 -1 0 1]
I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.whisper.android.tflitecpp
I/art: Late-enabling -Xcheck:jni
D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.whisper.android.tflitecpp, PID: 25507
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol “strtod_l” referenced by “/data/app/com.whisper.android.tflitecpp-1/base.apk!/lib/arm64-v8a/libtensorflowlite.so”…
at java.lang.Runtime.loadLibrary0(Runtime.java:977)
at java.lang.System.loadLibrary(System.java:1567)
at com.whisper.android.tflitecpp.MainActivity.(MainActivity.java:59)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Are you there sir can you check my code please

Hy sir can you provide the simple code

use this https://github.com/nyadla-sys/whisper.tflite/tree/main/android_example

@It_Solution it seems the problem you are hitting is the unavailability of the strtod_l on your specific platform. I am getting a similar error with an Android 7.1.1 device.

I filed an issue here: