Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Appending TTS Engine Next Generation by @jing332 #726

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .gitmodules
Empty file.
38 changes: 38 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Android CI (Test)

on:
push:
branches:
- "master"
paths-ignore:
- "**.md"
- "images/**"
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle

- name: Build
run: |
chmod +x *.sh
./install-solib.sh

chmod +x gradlew
./gradlew assembleRelease --build-cache --parallel --daemon --warning-mode all

- name: Upload apk
uses: actions/upload-artifact@v4
with:
name: app-release
path: "${{ github.workspace }}/app/build/outputs/apk/release/*.apk"
58 changes: 58 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build Release

on:
push:
branches:
- "master"
paths:
- "CHANGELOG.md"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
env:
outputs_dir: "${{ github.workspace }}/app/build/outputs"
ver_name: ""

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v3

- name: Build
run: |
chmod +x *.sh
./install-solib.sh

chmod +x gradlew
./gradlew assembleRelease --build-cache --parallel --daemon --warning-mode all

- name: Init environment variable
run: |
echo "ver_name=$(grep -m 1 'versionName' ${{ env.outputs_dir }}/apk/release/output-metadata.json | cut -d\" -f4)" >> $GITHUB_ENV

- name: Upload Mappings to Artifact
uses: actions/upload-artifact@v4
with:
name: mappings_${{ env.ver_name }}
path: ${{ env.outputs_dir }}/mapping/*/*.txt

- uses: softprops/action-gh-release@v2
with:
name: ${{ env.ver_name }}
tag_name: ${{ env.ver_name }}
body_path: ${{ github.workspace }}/CHANGELOG.md
draft: false
prerelease: false
files: ${{env.outputs_dir}}/apk/release/*.apk
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
15 changes: 15 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
5 changes: 5 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Batch delete model
- Export model to zip
- Github proxy url
- Add tips
- refactor model and voice, and support speaker id.
36 changes: 36 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[![Android CI (Test)](https://github.com/jing332/SherpaOnnxTtsEngineAndroid/actions/workflows/build.yml/badge.svg)](https://github.com/jing332/SherpaOnnxTtsEngineAndroid/actions/workflows/build.yml)
[![Build Release](https://github.com/jing332/SherpaOnnxTtsEngineAndroid/actions/workflows/release.yml/badge.svg)](https://github.com/jing332/SherpaOnnxTtsEngineAndroid/actions/workflows/release.yml)

![GitHub release](https://img.shields.io/github/downloads/jing332/SherpaOnnxTtsEngineAndroid/total)
![GitHub release (latest by date)](https://img.shields.io/github/downloads/jing332/SherpaOnnxTtsEngineAndroid/latest/total)

# SherpaOnnxTtsEngineAndroid

> [!NOTE]
> Automatic downloading and installation of models is now supported!

<details>
<summary>Original steps</summary>

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

then:

1. Open Application -> Import model package -> choose *.tar.bz2 model file -> Wait for the import to
complete.

> or manual import:

1. Unzip to Android/data/com.k2fsa.sherpa.onnx.tts.engine/files/model
2. Open Application -> Add models

> On Android 13+ devices, use [MT Manager](https://mt2.cn/download/)
> or [Material Files](https://github.com/zhanghai/MaterialFiles)
> or [MiXplorer](https://xdaforums.com/t/app-2-2-mixplorer-v6-x-released-fully-featured-file-manager.1523691/)
> to access the Android/data path.

</details>

# Preview

<img src="./images/1.jpg" height="150px" alt="1">
2 changes: 2 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/build
*.so
155 changes: 155 additions & 0 deletions android/SherpaOnnxTtsEngine-NG/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import java.text.SimpleDateFormat
import java.util.Date
import java.util.TimeZone

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlinx-serialization")

}

val buildTime: Long
get() {
val t = Date().time / 1000
return t
}

val releaseTime: String
get() {
val sdf = SimpleDateFormat("yy.MMddHH")
sdf.timeZone = TimeZone.getTimeZone("GMT+8")
return sdf.format(Date())
}

val version = "1.$releaseTime"

val gitCommits: Int
get() {
val process = ProcessBuilder("git", "rev-list", "HEAD", "--count").start()
return process.inputStream.reader().use { it.readText() }.trim().toInt()
}
android {
namespace = "com.k2fsa.sherpa.onnx.tts.engine"
compileSdk = 34

defaultConfig {
applicationId = "com.k2fsa.sherpa.onnx.tts.engine"
minSdk = 21
targetSdk = 34
versionCode = gitCommits
versionName = version

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

signingConfigs {
create("release") {
storeFile = file("sherpa-onnx.jks")
storePassword = "sherpa-onnx"
keyAlias = "sherpa-onnx"
keyPassword = "sherpa-onnx"
}
}

buildTypes {
release {
signingConfig = signingConfigs["release"]
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}

debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "_debug"
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.8"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4")

implementation("androidx.localbroadcastmanager:localbroadcastmanager:1.1.0")

implementation("com.squareup.okio:okio:3.3.0")
implementation("com.squareup.okhttp3:okhttp:4.11.0")
implementation("com.github.liangjingkanji:Net:3.6.4")

implementation("androidx.navigation:navigation-compose:2.7.7")
implementation("androidx.documentfile:documentfile:1.0.1")

implementation("org.apache.commons:commons-compress:1.26.0")
implementation("commons-codec:commons-codec:1.16.1")

implementation("org.tukaani:xz:1.9")


implementation("com.geyifeng.immersionbar:immersionbar:3.2.2")
implementation("com.geyifeng.immersionbar:immersionbar-ktx:3.2.2")

implementation("com.charleskorn.kaml:kaml:0.57.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")

implementation("com.github.FunnySaltyFish.ComposeDataSaver:data-saver:v1.1.5")
implementation("org.burnoutcrew.composereorderable:reorderable:0.9.6")

val accompanistVersion = "0.34.0"
implementation("com.google.accompanist:accompanist-systemuicontroller:${accompanistVersion}")
// implementation("com.google.accompanist:accompanist-navigation-animation:${accompanistVersion}")
implementation("com.google.accompanist:accompanist-permissions:${accompanistVersion}")


implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")
implementation("androidx.navigation:navigation-compose:2.7.7")

implementation("io.github.dokar3:sheets-m3:0.5.4")

val composeBom = platform("androidx.compose:compose-bom:2024.02.01")
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
implementation("androidx.activity:activity-compose:1.8.2")
implementation(composeBom)
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.appcompat:appcompat:1.6.1")

// implementation("androidx.compose.material3:material-icons-core")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(composeBom)
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
Loading