Android Chinese TTS Engine Base On Tensorflow TTS , use for TfLite Models Test。安卓离线中文TTS引擎,在TensorflowTTS基础上开发,用于TfLite模型测试。

Overview

Chinese TTS TF Lite

Issue Star

介绍

使用Kotlin + JetPack Compose + Tensorflow Lite开发的TTS引擎,可以完全离线使用。

可选两种模型:FastSpeech和Tacotron,这两种模型均来自TensorFlowTTS

文字转拼音方法来自:TensorflowTTS_chinese

因为是实时推理输出音频,故对设备性能有一定要求。

其中FastSpeech速度较快,但生成的音频拟人效果较差,可以用于普通中端以上手机。

而Tacotron对性能要求较高,虽然总体效果更好,但因为速度很慢,故目前实用价值不大,仅供测试。

手动编译说明

  1. Android 2020.3.1 Patch 2
  2. 从下面的模型下载地址,下载models-tflite.7z,把如下4个文件解压到对应目录
├─app/src/main/assets
│      baker_mapper.json
│      fastspeech2_quan.tflite
│      mb_melgan.tflite
│      tacotron2_quan.tflite
  1. 编译
./gradlew assembleRelease

模型下载

下载地址

  • models-tf.7z : 原始TensorflowTTS模型,一般用于PC端
  • models-tflite.7z : 转换后的TFLite模型,一般用于移动端

模型查看

netron

参考资料

TensorFlowTTS

TensorflowTTS_chinese

tensorflow指南

参考tf测试

参考tflite转换

Google Pico TTS Source

模型测试&转换

转换环境配置

  • Ubuntu: 20.04 LTS
  • Python: 3.8
$ git clone https://github.com/TensorSpeech/TensorFlowTTS.git
$ cd TensorFlowTTS
$ pip install .
$ pip install git+https://github.com/repodiac/german_transliterate.git

解压models-tf.7z

TF模型测试

$ cd models-tf
$ python test-h5.py

TF模型转TFLite

$ python convert-tflite.py

APP界面截图

avatar

You might also like...
Android Bitcoin market app base on Jetpack Compose and MVI. The app displays current bitcoin market price and history price k-line charts.

compose-bitcoin Android Bitcoin market app base on Jetpack Compose and MVVM & MVI. Features Current bitcoin market price. K-line charts of history pri

An Android base project building on MVVM Architecture Pattern. This can help you build new apps faster
An Android base project building on MVVM Architecture Pattern. This can help you build new apps faster

MVVM Explanation If you can't imagine what is MVVM, please read my medium article here first. It can fully explain the revolution of Software architec

A code base to retrieve flight schedules and demonstrate heavy modularisation.

FS2020 Flight Scheduler This will eventually produce an application that allows us to convert real life traffic from any source into traccic that can

Base project for Devpass' Dev Sprints

Foundations Kotlin Challenge In this challenge, we're going to develop a simple Kotlin application where we'll apply language fundamental features. Co

ArchGuard Scanner for scan Git change history, scan source code by Chapi for Java, TypeScript, Kotlin, Go..、Java bytecode use for JVM languages, scan Jacoco test coverage.

Arch Scanner Requirements: JDK 12 Scanner: scan_git - Git commit history scan scan_jacoco - Jacoco scan scan_bytecode - for JVM languages known issues

Material Design 3 Theme Engine for Android
Material Design 3 Theme Engine for Android

A Material Design 3 Theme Engine for Android This library allows you to set Material 3 themes to your app. You can also manage dark mode and dynamic c

Kotlin Spring Boot on GCP App Engine Standard

Kotlin Spring Boot on GCP App Engine Standard Deploy locally git clone https://github.com/mvladoi/sinch-task.git cd springboot mvn spring-boot:run 7

DroidFish is a feature-rich graphical chess user interface, combined with the very strong Stockfish chess engine.
DroidFish is a feature-rich graphical chess user interface, combined with the very strong Stockfish chess engine.

Introduction DroidFish is a feature-rich graphical chess user interface, combined with the very strong Stockfish chess engine. DroidFish is primarily

Comments
  • 如何直接使用编译好的so库?

    如何直接使用编译好的so库?

    你好!我想直接使用编译好的so库,不用在gradle里使用implementation,这个如何操作?我按照网上介绍的方法把so对应cpu的文件夹和文件放入到libs,然后在gradle里增加ndk和sourceSets。但运行却出现找不到org.tensorflow.lite.Interpreter类的错误,我也用loadlibrary加载了so,不知道还需要哪些配置?希望得到帮助,谢谢!

    opened by watersoft123 5
  • 运行时这个错误,请问怎么解决?

    运行时这个错误,请问怎么解决?

    2022-12-30 16:20:01.680 10684-10684/com.benjaminwan.chinesettstflite E/AndroidRuntime: FATAL EXCEPTION: main Process: com.benjaminwan.chinesettstflite, PID: 10684 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.benjaminwan.chinesettstflite/com.benjaminwan.chinesettstflite.ui.MainActivity}: java.lang.IllegalArgumentException: Contents of /data/user/0/com.benjaminwan.chinesettstflite/files/fastspeech2_quan.tflite does not encode a valid TensorFlow Lite model: Mmap of '60' at offset '0' failed with error '22'. The model allocation is null/empty at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:201) at android.app.ActivityThread.main(ActivityThread.java:6810) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) Caused by: java.lang.IllegalArgumentException: Contents of /data/user/0/com.benjaminwan.chinesettstflite/files/fastspeech2_quan.tflite does not encode a valid TensorFlow Lite model: Mmap of '60' at offset '0' failed with error '22'. The model allocation is null/empty at org.tensorflow.lite.NativeInterpreterWrapper.createModel(Native Method) at org.tensorflow.lite.NativeInterpreterWrapper.(NativeInterpreterWrapper.java:50) at org.tensorflow.lite.NativeInterpreterWrapperExperimental.(NativeInterpreterWrapperExperimental.java:40) at org.tensorflow.lite.Interpreter.(Interpreter.java:196) at com.benjaminwan.chinesettstflite.tts.FastSpeech2.(FastSpeech2.kt:12) at com.benjaminwan.chinesettstflite.tts.TtsManager.initModels(TtsManager.kt:86) at com.benjaminwan.chinesettstflite.ui.MainActivity.onCreate(MainActivity.kt:25) at android.app.Activity.performCreate(Activity.java:7224) at android.app.Activity.performCreate(Activity.java:7213) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926) ... 11 more

    opened by lrf1027430 4
  • 优化转换PCM 16BIT的方法

    优化转换PCM 16BIT的方法

    此处转换成PCM_16BIT的方法效率太低了,会导致停顿特别长,可以试试下面的方法。

    https://github.com/benjaminwan/ChineseTtsTflite/blob/35bb08c9335d3d3577cc39800490eb5106a07855/app/src/main/java/com/benjaminwan/chinesettstflite/tts/TtsManager.kt#L159

        private byte[] convertTo16Bit(float[] data) {
            byte[] byte16bit=new byte[data.length<<1];
            for (int i = 0; i < data.length; i++) {
                short temp=(short) (32768 * data[i]);
                byte16bit[i * 2] = (byte) (temp);
                byte16bit[i * 2 + 1] = (byte) (temp >> 8);
            }
            return byte16bit;
        }
    
    opened by ag2s20150909 1
Releases(0.5.0)
  • 0.5.0(Apr 23, 2022)

    • 2022-04-23 15:00:41 benjaminwan: edit README.md
    • 2022-04-23 14:58:39 benjaminwan: edit build.gradle
    • 2022-04-23 14:54:50 benjaminwan: move aars dir
    • 2022-04-23 14:53:28 benjaminwan: edit .gitignore
    • 2022-04-23 14:45:19 benjaminwan: edit README.md
    • 2022-04-23 14:43:40 benjaminwan: edit github workflows: 增加步骤下载tensorflow-lite-aars
    • 2022-04-23 14:40:29 benjaminwan: versionName: 0.5.0, versionCode:5
    • 2022-04-23 14:39:50 benjaminwan: 使用裁剪编译的tensorflow-lite
    • 2022-04-23 14:38:15 benjaminwan: .getignore
    • 2022-04-23 14:37:46 benjaminwan: edit README.md
    • 2022-04-21 16:09:19 benjaminwan: edit README.md
    • 2022-04-21 14:34:12 benjaminwan: 标题显示版本号
    • 2022-04-21 14:21:13 benjaminwan: convertTo16Bit方法改用kotlin实现
    • 2022-04-21 10:52:57 benjaminwan: inputTextJob 在Main线程调用,避免线程同步问题
    • 2022-04-21 10:52:03 benjaminwan: currentLanguage改用MutableList来存储
    • 2022-04-21 10:50:38 benjaminwan: 调整设置界面UI
    • 2022-04-21 09:24:46 benjaminwan: tensorflow-lite: 2.8.0, tf-ops: 2.8.0, lite-support:0.3.1
    • 2022-04-21 09:18:57 benjaminwan: compose_version: 1.1.1, gradle: 7.1.3
    Source code(tar.gz)
    Source code(zip)
    ChineseTtsTflite-0.5.0-release.apk(80.84 MB)
  • 0.4.0(Feb 23, 2022)

    • 2022-02-23 15:18:33 benjaminwan: edit README.md
    • 2022-02-23 15:17:38 benjaminwan: versionName: 0.4.0, versionCode: 4
    • 2022-02-23 15:17:11 benjaminwan: 提升转换速度:convertTo16Bit()替换toByteArray()方法
    • 2022-02-23 15:11:53 benjaminwan: core-ktx:1.7.0, appcompat:1.4.1, material:1.5.0, activity-compose:1.4.0, Lifecycle: 2.4.1
    • 2022-02-23 15:11:14 benjaminwan: compose: 1.1.0, kotlin: 1.6.10
    • 2022-02-23 14:33:01 benjaminwan: gradle: 7.1.1, gradle-wrapper: 7.2
    • 2021-09-05 18:10:34 benjaminwan: edit README.md
    • 2021-09-03 17:51:12 benjaminwan: edit README.md
    Source code(tar.gz)
    Source code(zip)
    ChineseTtsTflite-0.4.0-release.apk(152.71 MB)
  • 0.3.0(Sep 3, 2021)

    • 2021-09-03 17:40:37 benjaminwan: edit README.md
    • 2021-09-03 17:39:07 benjaminwan: versionName: 0.3.0
    • 2021-09-03 17:38:27 benjaminwan: edit README.md
    • 2021-09-03 17:35:13 benjaminwan: add screen capture
    • 2021-09-03 17:32:06 benjaminwan: Edit README.md
    • 2021-09-03 17:30:31 benjaminwan: reformat code
    • 2021-09-03 16:53:14 benjaminwan: 使用TextToSpeech代替TtsManager控制朗读
    • 2021-09-03 15:19:28 benjaminwan: 添加同步方法speechAsync
    • 2021-09-03 14:26:22 benjaminwan: path
    • 2021-09-03 14:22:57 benjaminwan: 添加GetSampleText
    • 2021-09-03 11:43:58 benjaminwan: 改进CheckVoiceData
    • 2021-09-03 11:43:26 benjaminwan: 添加DownloadVoiceData
    • 2021-09-02 15:55:56 benjaminwan: gradle: 7.0.2
    • 2021-09-01 16:48:24 benjaminwan: edit README.md
    Source code(tar.gz)
    Source code(zip)
    ChineseTtsTflite-0.3.0-release.apk(152.28 MB)
  • 0.2.0(Aug 31, 2021)

    • 2021-08-31 17:58:29 benjaminwan: versionName: 0.2.0
    • 2021-08-31 17:44:33 benjaminwan: 添加 MoshiUtils 用于保存设置项
    • 2021-08-31 17:28:33 benjaminwan: 添加 设置TTS按钮
    • 2021-08-31 17:24:40 benjaminwan: 实现TtsService
    • 2021-08-31 09:44:45 benjaminwan: 修改报名,添加空Service
    • 2021-08-31 08:12:03 benjaminwan: clean
    Source code(tar.gz)
    Source code(zip)
    ChineseTtsTflite-0.2.0-release.apk(152.28 MB)
  • 0.1.0(Aug 30, 2021)

    • 2021-08-30 23:25:58 benjaminwan: add github workflow config
    • 2021-08-30 23:13:31 benjaminwan: add signingConfigs
    • 2021-08-30 22:11:45 benjaminwan: edit README.md
    • 2021-08-30 20:07:29 benjaminwan: 修改Title
    • 2021-08-30 20:03:09 benjaminwan: format code
    • 2021-08-30 19:56:12 benjaminwan: fix: 空语句朗读错误
    • 2021-08-30 18:02:05 benjaminwan: 完成TtsManager,实现状态显示
    • 2021-08-30 18:00:53 benjaminwan: edit build.gradle, add pinyin4j
    • 2021-08-30 11:02:14 benjaminwan: edit build.gradle, add Tensorflow Lite
    • 2021-08-30 10:56:39 benjaminwan: Application
    • 2021-08-30 10:55:54 benjaminwan: edit build.gradle, add Logger
    • 2021-08-30 10:43:38 benjaminwan: 测试界面编写
    • 2021-08-30 10:07:43 benjaminwan: 修改ic_launcher
    • 2021-08-30 09:44:11 benjaminwan: edit gitignore
    • 2021-08-30 09:15:59 benjaminwan: edit README.md
    • 2021-08-28 18:01:17 benjaminwan: edit README.md
    • 2021-08-28 17:46:00 benjaminwan: edit README.md
    Source code(tar.gz)
    Source code(zip)
    ChineseTtsTflite-0.1.0-release.apk(151.50 MB)
  • init(Aug 28, 2021)

    模型下载

    • models-tf.7z : 原始TensorflowTTS模型
    • models-tflite.7z : 转换后的TF Lite模型

    定制编译版tensorflow-lite

    依据模型使用的算子,定制缩减编译的版本。 裁剪前后的arr文件大小对比:

    • tensorflow-lite-2.8.0.aar: 5.4MB -> 3.7MB (68.5%)
    • tensorflow-lite-select-tf-ops-2.8.0.aar: 109.6MB -> 14.8MB (13.5%)
    Source code(tar.gz)
    Source code(zip)
    models-tf.7z(173.26 MB)
    models-tflite.7z(40.18 MB)
    tensorflow-lite-2.8.0.aar(3.73 MB)
    tensorflow-lite-select-tf-ops-2.8.0.aar(14.81 MB)
Owner
benjamin wan
benjamin wan
A Full-Stack mobile app, including Android & Server, Simple-Poem 简诗. You can write poem in graceful & traditional Chinese style.

JianShi 简诗 A Full-Stack mobile app, including Android side & Server side, Simple-Poem 简诗. You can write poem in graceful & traditional Chinese style.

wingjay 1.9k Jan 6, 2023
Age + Gender Estimation on Android - with TensorFlow Lite

Age + Gender Estimation in Android with TensorFlow Contents Python project Google Colab Notebooks Dataset Model ( Vanilla vs. Lite ) Android project O

Shubham Panchal 32 Dec 8, 2022
This document will walk you through the steps for creating your Android app that runs a deep learning image classification model trained in Pocket AutoML and exported in TensorFlow Lite format

Pocket AutoML: Tutorial for Creating an Android App for Image Classification with Deep Learning Translations English (this document) Русский Overview

Evgeniy Mamchenko 15 Nov 22, 2022
This app using Mlkit along with the TensorFlow Lite model for object detection,

I built this app using Mlkit along with the TensorFlow Lite model for object detection, Arcore is used to place anchors to the detected objects. It's a good blend of Machine learning and Augmented reality to visualise ML information in a much better way than regular bounding boxes

Kashif Mehmood 18 Nov 10, 2022
Extensible Android mobile voice framework: wakeword, ASR, NLU, and TTS. Easily add voice to any Android app!

Spokestack is an all-in-one solution for mobile voice interfaces on Android. It provides every piece of the speech processing puzzle, including voice

Spokestack 57 Nov 20, 2022
Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

Jacob Lim 1 Oct 28, 2021
Clean Architecture Kotlin Multiplatform Mobile (KMM) with Android Instrument Test and Unit Test

The-Movies: Clean Architecture Kotlin Multiplatform Mobile What're inside? - Jetpack Compose - Hilt - Ktor - Android Instrument Test - Unit Test - SQL

null 17 Dec 5, 2022
Displayin 3D models (.glTF, .glb) in an android app

3D Model Presenting in Android This is a sample android app to present any 3D model with .glb or .glTF extension by using one of 2 easy ways. Aim of t

Onuralp AVCI 8 Dec 2, 2022
Warscape core library. Includes common models for sharing between platforms.

warscope-core This repository uses for sharing common models between backend and frontend sides. Implementation $version available at top of README.md

Warscape 5 Oct 8, 2021
🏛 ThinkRchive Light Dark An app showing all details for various Lenovo Thinkpad models.

?? ThinkRchive Light Dark An app showing all details for various Lenovo Thinkpad models. Made to try out Jepack Compose for Android. This repo is a Mu

Thinkrchive 59 Dec 28, 2022