Skip to content

Commit

Permalink
Initial working commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BentiGorlich committed Sep 14, 2023
1 parent 7443c0b commit dc993a2
Show file tree
Hide file tree
Showing 56 changed files with 3,089 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .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
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Mimic3 TTS Service Wrapper For Android
This app is a wrapper around the mimic3 webserver. It registers itself to android, so you can use it system wide.
At the moment this app requires a running mimic3 server, but in the future it might be able to run locally.
For that to work the main problem is, that the `onnxruntime` which mimic3 depends on is not supported
by the gradle plugin `chaquopy`, which enables Android apps to use python packages. See [#216](https://github.com/chaquo/chaquopy/issues/216) in the [chaquopy](https://github.com/chaquo/chaquopy) repo

![Mimic3 Logo](https://github.com/MycroftAI/mimic3/raw/master/img/Mimic_color.svg) [Mimic3](https://github.com/MycroftAI/mimic3)

# Quickstart

You need:
1. Android phone running Android 7 or above
2. A machine running the mimic3 webserver
3. A router which can forward ports (or an exposed webserver)

In the app you can set the server address of your server. In the future I may provide a default one.
There is a docker image for the mimic3 webserver: `mycroftai/mimic3` [doc](https://mycroft-ai.gitbook.io/docs/mycroft-technologies/mimic-tts/mimic-3#docker-image)

NOTE: you have to run this behind a reverse proxy, because android forbids traffic to http websites by default.
I use a docker image for that: `jc21/nginx-proxy-manager` [doc](https://github.com/NginxProxyManager/nginx-proxy-manager)

# Features

- Uses Mimic3 a open source, fast and good quality TTS engine
- Mimic3 server can run on low-end hardware like the Raspberry Pi 4
- Supports 25 languages with multiple voices and speakers, see [Mimic3 voices](https://github.com/MycroftAI/mimic3-voices) for more details
- Supports caching
- Settings for speech speed, audio volatility, phoneme volatility and cache size. An explanation of audio and phoneme volatility is available by clicking on their labels

# Screenshots
| Main Screen | Settings Screen |
| - | - |
| ![Main Screen](images/Main.png) | ![Settings Screen](images/Settings.png) |
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
56 changes: 56 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
plugins {
id 'com.android.application'
//id 'com.chaquo.python'
}

android {
namespace 'de.bentigorlich.mimic3ttsenginewrapper'
compileSdk 33

defaultConfig {
applicationId "de.bentigorlich.mimic3ttsenginewrapper"
minSdk 26
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

ndk {
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}

//python {
// version "3.8"
// pip {
// install "mycroft-mimic3-tts[all]"
// }
//}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.code.gson:gson:2.10.1'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package de.bentigorlich.mimic3ttsenginewrapper;

import android.content.Context;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("de.bentigorlich.mozillattsenginewrapper", appContext.getPackageName());
}
}
63 changes: 63 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".Mimic3TTSEngineWrapperApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Mimic3TTSEngineWrapper"
tools:targetApi="31">
<activity
android:name=".CheckTTSDataActivity"
android:exported="true"
android:theme="@style/Theme.Mimic3TTSEngineWrapper">
<intent-filter>
<action android:name="android.speech.tts.engine.CHECK_TTS_DATA" />
<action android:name="android.speech.tts.engine.GET_SAMPLE_TEXT" />
<action android:name="android.speech.tts.engine.INSTALL_TTS_DATA" />
<action android:name="android.speech.tts.engine.CONFIGURE_ENGINE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:exported="false"
android:label="@string/title_activity_settings"
android:theme="@style/Theme.Mimic3TTSEngineWrapper" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.speech.tts.engine.CONFIGURE_ENGINE" />
</intent-filter>
</activity>

<service
android:name=".Mimic3TTSEngineWeb"
android:description="@string/service_description"
android:directBootAware="true"
android:enabled="true"
android:exported="true"
android:label="@string/service_name">
<intent-filter>
<action android:name="android.intent.action.TTS_SERVICE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>

<meta-data
android:name="android.speech.tts"
android:resource="@xml/tts_engine" />
</service>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.bentigorlich.mimic3ttsenginewrapper;

import androidx.annotation.NonNull;

import java.util.Date;

public class CacheEntry implements Cloneable {
public String Text;
public Date LastUsed;
public long ByteSize;

@NonNull
@Override
public CacheEntry clone() {
CacheEntry copy = new CacheEntry();
copy.Text = Text;
copy.LastUsed = LastUsed;
copy.ByteSize = ByteSize;
return copy;
}
}
Loading

0 comments on commit dc993a2

Please sign in to comment.