first-command
This commit is contained in:
commit
c62c083f5c
63 changed files with 2675 additions and 0 deletions
48
.gitignore
vendored
Normal file
48
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# Intellij
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/modules.xml
|
||||
.idea/misc.xml
|
||||
.idea/libraries
|
||||
.idea/vcs.xml
|
||||
.idea/codeStyleSettings.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
22
.idea/compiler.xml
generated
Normal file
22
.idea/compiler.xml
generated
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
3
.idea/copyright/profiles_settings.xml
generated
Normal file
3
.idea/copyright/profiles_settings.xml
generated
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
18
.idea/gradle.xml
generated
Normal file
18
.idea/gradle.xml
generated
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
12
.idea/runConfigurations.xml
generated
Normal file
12
.idea/runConfigurations.xml
generated
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
27
app/build.gradle
Normal file
27
app/build.gradle
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 24
|
||||
buildToolsVersion '25.0.0'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.voixtreme.vocalengine"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 24
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
compile files('libs/vocalizerlib.jar')
|
||||
}
|
||||
BIN
app/libs/vocalizerlib.jar
Normal file
BIN
app/libs/vocalizerlib.jar
Normal file
Binary file not shown.
17
app/proguard-rules.pro
vendored
Normal file
17
app/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in C:\Android\android-sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# 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 *;
|
||||
#}
|
||||
BIN
app/src.7z
Normal file
BIN
app/src.7z
Normal file
Binary file not shown.
|
|
@ -0,0 +1,13 @@
|
|||
package com.voixtreme.vocalengine;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
51
app/src/main/AndroidManifest.xml
Normal file
51
app/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.voixtreme.vocalengine">
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<!-- RECORD_AUDIO is needed to create an audio recorder -->
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||
|
||||
<!-- MODIFY_AUDIO_SETTINGS is needed to use audio effects -->
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
|
||||
|
||||
<!-- INTERNET is needed to use a URI-based audio player, depending on the URI -->
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Transparent">
|
||||
|
||||
<activity android:name="com.voixtreme.vocalengine.MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<action android:name="com.nuance.vocalizer.VOCALIZER_DATA" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name="com.voixtreme.vocalengine.service.VoiXtremeService"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop" >
|
||||
</service>
|
||||
|
||||
<receiver
|
||||
android:name="com.voixtreme.vocalengine.receivers.BootReceiver"
|
||||
android:enabled="true"
|
||||
android:label="@string/BootReceiver" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
124
app/src/main/java/com/voixtreme/vocalengine/MainActivity.java
Normal file
124
app/src/main/java/com/voixtreme/vocalengine/MainActivity.java
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
package com.voixtreme.vocalengine;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.voixtreme.vocalengine.service.VoiXtremeService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
//=============================================================================
|
||||
// This activity does nothing, and holds the service
|
||||
public class MainActivity extends Activity {
|
||||
private static final String TAG = MainActivity.class.getSimpleName();
|
||||
|
||||
private static final int REQUEST_CODE_PERMISSIONS = 313;
|
||||
|
||||
|
||||
//=========================================================================
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (permissionsOK()) {
|
||||
startApplication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start application when all permissions have been granted
|
||||
*/
|
||||
private void startApplication() {
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
startVoixtremeService();
|
||||
|
||||
// Please comment this if you are debugging to keep the activity alive
|
||||
finish();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Start the service by an intent (if not already started in boot)
|
||||
private void startVoixtremeService() {
|
||||
|
||||
Intent intentService = new Intent(this, VoiXtremeService.class);
|
||||
startService(intentService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all required permissions
|
||||
*
|
||||
* @return true if all permissions where given already...
|
||||
*/
|
||||
private boolean permissionsOK() {
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ArrayList<String> getPermissionsList = new ArrayList<>();
|
||||
|
||||
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getPermissionsList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
|
||||
if (checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
||||
getPermissionsList.add(Manifest.permission.RECORD_AUDIO);
|
||||
}
|
||||
|
||||
if (getPermissionsList.size() > 0) {
|
||||
String requestStrings[] = new String[getPermissionsList.size()];
|
||||
for (int i=0, len=getPermissionsList.size();i<len;i++) {
|
||||
requestStrings[i] = getPermissionsList.get(i);
|
||||
}
|
||||
|
||||
ActivityCompat.requestPermissions(this, requestStrings, REQUEST_CODE_PERMISSIONS);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
boolean granted = true;
|
||||
|
||||
for (int result : grantResults) {
|
||||
if(result != PackageManager.PERMISSION_GRANTED) {
|
||||
granted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (granted) {
|
||||
startApplication();
|
||||
} else {
|
||||
Toast.makeText(this.getApplicationContext(), R.string.need_permissions, Toast.LENGTH_LONG).show();
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
finish();
|
||||
}
|
||||
}, 2500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.voixtreme.vocalengine.receivers;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.voixtreme.vocalengine.service.VoiXtremeService;
|
||||
|
||||
//=============================================================================
|
||||
/**
|
||||
* Created by JMA and CZon 17-Aug-16.
|
||||
*/
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
// Tag
|
||||
private static final String TAG = BootReceiver.class.getSimpleName();
|
||||
|
||||
// Methods
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||
try {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putBoolean("initialized", true).commit();
|
||||
context.startService(new Intent(context, VoiXtremeService.class));
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
package com.voixtreme.vocalengine.receivers;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.voixtreme.vocalengine.service.VoiXtremeService;
|
||||
import com.voixtreme.vocalengine.service.VxtCommandManager;
|
||||
import com.voixtreme.vocalengine.service.VxtAsrStateManager;
|
||||
import com.voixtreme.vocalengine.service.VxtPkgManager;
|
||||
import com.voixtreme.vocalengine.service.VxtTtsManager;
|
||||
|
||||
//=============================================================================
|
||||
/**
|
||||
* Created by CZ + Jimmie
|
||||
* This class will receive the intents form the App that is using the VoiXtreme service.
|
||||
* It generates a broadcast message to handler on Service
|
||||
*/
|
||||
public class VoiXtremeReceiver extends BroadcastReceiver {
|
||||
|
||||
// Package, language and voice
|
||||
private VxtPkgManager pkgManager;
|
||||
|
||||
// The data sent / received through intents with voice commands
|
||||
private VxtCommandManager[] commandManager;
|
||||
private int cmdIdx=0;
|
||||
|
||||
// ASR state
|
||||
private VxtAsrStateManager asrStateManager;
|
||||
|
||||
// The data for TTS engine
|
||||
private VxtTtsManager ttsManager;
|
||||
|
||||
// Handler to dispatch internally
|
||||
private VoiXtremeService.IncomingHandler mHandler;
|
||||
|
||||
// Tag
|
||||
private static final String TAG = VoiXtremeReceiver.class.getSimpleName();
|
||||
|
||||
// Intent data ------
|
||||
|
||||
// To be received from Emulator App
|
||||
public static final String BROADCAST_RECEIVE_INTENT_COMMAND = "com.voixtreme.vocalengine.COMMAND";
|
||||
|
||||
// Intent Data
|
||||
public static final String EXTRAS_COMMAND = "COMMAND";
|
||||
public static final String EXTRAS_TEXT = "TEXT";
|
||||
public static final String EXTRAS_PACKAGE = "PACKAGE";
|
||||
public static final String EXTRAS_RELIABILITY = "RELIABILITY";
|
||||
public static final String EXTRAS_VOICES = "VOICES";
|
||||
public static final String EXTRAS_REGISTER = "REGISTER";
|
||||
public static final String EXTRAS_ASRSTATE = "ASRSTATE";
|
||||
public static final String EXTRAS_ID = "ID";
|
||||
|
||||
public static final int COMMAND_UNKNOWN = -1;
|
||||
public static final int COMMAND_INITIALIZE_ALL = 0;
|
||||
public static final int COMMAND_INITIALIZE_TTS = 1;
|
||||
public static final int COMMAND_FINALIZE = 2;
|
||||
public static final int COMMAND_SPEECH = 3;
|
||||
public static final int COMMAND_STATE = 4;
|
||||
public static final int COMMAND_PING = 10;
|
||||
public static final int COMMAND_TTS = 99;
|
||||
|
||||
|
||||
//=============================================================================
|
||||
// Intent receiver, performs a local message to handle
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
final String action = intent.getAction();
|
||||
|
||||
if ( action == BROADCAST_RECEIVE_INTENT_COMMAND) // Received from Emulator
|
||||
{
|
||||
if (commandManager == null) {
|
||||
// TODO: exception
|
||||
return;
|
||||
}
|
||||
|
||||
// The command
|
||||
int command = intent.getExtras().getInt(EXTRAS_COMMAND, COMMAND_UNKNOWN);
|
||||
// The response package
|
||||
if ( intent.hasExtra( EXTRAS_PACKAGE)) {
|
||||
String packageName= intent.getExtras().getString( EXTRAS_PACKAGE);
|
||||
pkgManager.setIntentPackage( packageName);
|
||||
asrStateManager.setIntentPackage( packageName);
|
||||
Log.i(TAG, "Intent PACKAGE =" + pkgManager.intentPackage);
|
||||
}
|
||||
|
||||
// Following received command IN INTENT
|
||||
switch(command) {
|
||||
// This command will load ASR and bqsic TTS libraries
|
||||
case COMMAND_INITIALIZE_ALL:
|
||||
//commandManager.setCommand(command, null);
|
||||
mHandler.sendMessage( Message.obtain( mHandler, command));
|
||||
break;
|
||||
|
||||
// This command will load the TTS selected voice
|
||||
case COMMAND_INITIALIZE_TTS:
|
||||
if ( intent.hasExtra( EXTRAS_VOICES)) {
|
||||
String selectedVoice= intent.getExtras().getString( EXTRAS_VOICES);
|
||||
Log.i(TAG, "Intent COMMAND_INITIALIZE_TTS SelectedVoice=");
|
||||
pkgManager.setVoice(selectedVoice );
|
||||
}
|
||||
else {
|
||||
Log.i(TAG, "Intent COMMAND_INITIALIZE_TTS ERROR NO VOICE!!");
|
||||
}
|
||||
//commandManager.setCommand(command, null);
|
||||
mHandler.sendMessage( Message.obtain( mHandler, command));
|
||||
break;
|
||||
|
||||
case COMMAND_FINALIZE:
|
||||
Log.i(TAG, "Intent COMMAND_FINALIZE");
|
||||
//commandManager.setCommand(command, null);
|
||||
mHandler.sendMessage( Message.obtain( mHandler, command));
|
||||
break;
|
||||
|
||||
case COMMAND_SPEECH:
|
||||
String voiceCommand = intent.getExtras().getString(EXTRAS_TEXT, "no text sent");
|
||||
String commandId = intent.getExtras().getString(EXTRAS_ID, "NO-ID");
|
||||
commandManager[cmdIdx].setCommand( voiceCommand, commandId);
|
||||
Message msg= Message.obtain( mHandler, command);
|
||||
msg.arg1= cmdIdx;
|
||||
Log.i(TAG, "Intent COMMAND_SPEECH VC=" + voiceCommand + " CI=" + commandId);
|
||||
mHandler.sendMessage( msg);
|
||||
cmdIdx++;
|
||||
if( cmdIdx >= 10)
|
||||
cmdIdx= 0;
|
||||
break;
|
||||
|
||||
case COMMAND_STATE:
|
||||
Log.i(TAG, "Intent COMMAND_STATE");
|
||||
if ( intent.hasExtra( EXTRAS_REGISTER)) {
|
||||
int registerEvent = intent.getExtras().getInt( EXTRAS_REGISTER);
|
||||
Log.i(TAG, "Intent COMMAND_STATE REGISTER=" + registerEvent );
|
||||
asrStateManager.setRegisterState( registerEvent);
|
||||
mHandler.sendMessage( Message.obtain( mHandler, command));
|
||||
}
|
||||
break;
|
||||
|
||||
case COMMAND_PING:
|
||||
Log.i(TAG, "Intent COMMAND_PING");
|
||||
// send back by intent response to ping
|
||||
Intent intentOut = new Intent( pkgManager.intentPackage);
|
||||
intentOut.putExtra(EXTRAS_COMMAND, COMMAND_PING);
|
||||
context.sendBroadcast(intentOut);
|
||||
Log.i(TAG, "Intent COMMAND_PING");
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: exception
|
||||
Log.e(TAG, "Intent ERROR command=" + command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Set the internal message cmd manager (incoming INTENTS)
|
||||
// Set the TTS messages manager
|
||||
// Set the internal Asr state manager
|
||||
public void setDataManagers( VxtPkgManager pkgManager, VxtCommandManager[] commandManager, VxtTtsManager vxtTtsManager, VxtAsrStateManager asrStateManager)
|
||||
{
|
||||
this.pkgManager = pkgManager;
|
||||
this.commandManager = commandManager;
|
||||
this.ttsManager= vxtTtsManager;
|
||||
this.asrStateManager = asrStateManager;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// Set the internal message handler
|
||||
public void setIncomingHandler(VoiXtremeService.IncomingHandler mHandler) {
|
||||
this.mHandler = mHandler;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,981 @@
|
|||
package com.voixtreme.vocalengine.service;
|
||||
|
||||
import android.app.Service;
|
||||
//import android.content.Context;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
//import android.os.Environment;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
//import android.widget.Toast;
|
||||
|
||||
import com.nuance.android.vocalizer.VocalizerEngine;
|
||||
import com.nuance.android.vocalizer.VocalizerEngineListener;
|
||||
import com.nuance.android.vocalizer.VocalizerVoice;
|
||||
import com.voixtreme.vocalengine.R;
|
||||
import com.voixtreme.vocalengine.receivers.VoiXtremeReceiver;
|
||||
import com.voixtreme.vxtenginejni.VxtEngineApi;
|
||||
|
||||
|
||||
//import java.io.File;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
//import java.util.Vector;
|
||||
|
||||
// Import constants for intents
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_INITIALIZE_ALL;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_INITIALIZE_TTS;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_SPEECH;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_STATE;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_TTS;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.EXTRAS_ASRSTATE;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.EXTRAS_COMMAND;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.EXTRAS_ID;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.EXTRAS_RELIABILITY;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.EXTRAS_TEXT;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.EXTRAS_VOICES;
|
||||
|
||||
//=============================================================================
|
||||
/**
|
||||
* Created by JMA + CZ on 7-Nov-16.
|
||||
* The service holds
|
||||
* - The VoiXtreme event Listener
|
||||
* - The Nuance TtsEngine with jar and API
|
||||
* - The VoiXtreme API
|
||||
* - The Handler system with async messages
|
||||
*/
|
||||
|
||||
/**
|
||||
* SERVICE
|
||||
* Outbond intents with voice commands (TAGS) are received by VoiXtremeReceiver
|
||||
*/
|
||||
public class VoiXtremeService extends Service
|
||||
implements VocalizerEngineListener {
|
||||
|
||||
// Intents and messages ----------------------------------------
|
||||
|
||||
// The VoiXtreme intents receiver
|
||||
private VoiXtremeReceiver voiXtremeReceiver= null;
|
||||
|
||||
// The event message handler
|
||||
private IncomingHandler mIncomingHandler= new IncomingHandler( this);
|
||||
|
||||
// Engines ASR and TTS -----------------------------------------
|
||||
|
||||
// The VoiXtreme API
|
||||
private VxtEngineApi mVxtEngineApi= null;
|
||||
|
||||
// Tts Vocalizer Engine: the text to speech engine.
|
||||
private VocalizerEngine ttsEngine = null;
|
||||
|
||||
private static final String VOIXTREME_SERVICE_VERSION = "4.1.1";
|
||||
|
||||
// Tag
|
||||
private static final String TAG = VoiXtremeService.class.getSimpleName();
|
||||
|
||||
// Data holders classes ------------------------------------
|
||||
|
||||
// This object contains the
|
||||
private VxtPkgManager mVxtManager = null;
|
||||
|
||||
private VxtPkgManager mVxtPkgManager = null;
|
||||
|
||||
// This object contains the command to VoiXtreme and ttsEngine
|
||||
private VxtCommandManager[] mVxtCommandManager = null;
|
||||
|
||||
// This object contains the command to ttsEngine
|
||||
private VxtTtsManager mVxtTtsManager= null;
|
||||
|
||||
// This object containts the ASR state data
|
||||
private VxtAsrStateManager mVxtAsrStateManager= null;
|
||||
|
||||
private boolean mIsVoiceLoaded= false;
|
||||
private boolean mIsSepaking = false;
|
||||
|
||||
// Available voices objects of tts engine
|
||||
private VocalizerVoice[] mVoicesAvailable = null;
|
||||
|
||||
// To save all tts engine voices NAMES (VocalizerVoice[].mVoiceName) from obb file into a MAP
|
||||
private Map<String, VocalizerVoice> mVoiceNamesListMap = null;
|
||||
|
||||
// comma separated list of voices names
|
||||
private String mVoicesNames;
|
||||
|
||||
// The ASR language configured (EN, FR, US)
|
||||
private String mAsrLanguageConfigured;
|
||||
|
||||
private boolean mIsInitializeTts= true;
|
||||
|
||||
private boolean mIsUniqueResponse= true;
|
||||
|
||||
// These values holds the current TTS engine parameters
|
||||
private class TtsParameters {
|
||||
public String mVoiceConfigured;
|
||||
public String mVoiceSelected;
|
||||
public int mVolume;
|
||||
public int mRate;
|
||||
public int mPitch;
|
||||
public long mRuleHandle= -1;
|
||||
}
|
||||
private TtsParameters mTtsCurParm = new TtsParameters();
|
||||
|
||||
// The current values for a say
|
||||
private class TtsSayData {
|
||||
public int mSayTtsId;
|
||||
public int mSayAsrMode;
|
||||
public int mSayTtsMode;
|
||||
public String mSayPhrase;
|
||||
public String mSayCommandId;
|
||||
}
|
||||
private TtsSayData mSay = new TtsSayData();
|
||||
|
||||
private class TtsValuesAndSettings {
|
||||
// Vocalizer Engine Parameters Range:
|
||||
// Volume:
|
||||
final int MIN_VOLUME = 0;
|
||||
final int MAX_VOLUME = 100;
|
||||
final int DEFAULT_VOLUME = 80;
|
||||
|
||||
// Pitch:
|
||||
final int MIN_PITCH = 50;
|
||||
final int MAX_PITCH = 200;
|
||||
final int DEFAULT_PITCH = 33;
|
||||
|
||||
// Rate:
|
||||
final int MIN_RATE = 50;
|
||||
final int MAX_RATE = 400;
|
||||
final int DEFAULT_RATE = 14;
|
||||
|
||||
final int MIN_PROPERTY = 0;
|
||||
final int MAX_PROPERTY = 100;
|
||||
}
|
||||
|
||||
private TtsValuesAndSettings mTtsConst = new TtsValuesAndSettings();
|
||||
|
||||
//=========================================================================
|
||||
// Service Overrides
|
||||
//=========================================================================
|
||||
|
||||
//=========================================================================
|
||||
// Service Overrides / Create the service
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
Log.i(TAG, "onCreate");
|
||||
|
||||
// The initial TTS CURRENT SAY values
|
||||
mSay.mSayTtsId= 0;
|
||||
mSay.mSayAsrMode= 0;
|
||||
mSay.mSayTtsMode= 0;
|
||||
mSay.mSayPhrase= "";
|
||||
|
||||
// The VoiXtreme engine
|
||||
mVxtEngineApi = new VxtEngineApi(this);
|
||||
|
||||
mVxtPkgManager = new VxtPkgManager();
|
||||
|
||||
mVxtCommandManager = new VxtCommandManager[10];
|
||||
// The command manager btw intent listener and service
|
||||
for( int i=0; i<10;i++) {
|
||||
mVxtCommandManager[i] = new VxtCommandManager();
|
||||
}
|
||||
|
||||
mVxtTtsManager= new VxtTtsManager();
|
||||
|
||||
mVxtAsrStateManager = new VxtAsrStateManager();
|
||||
|
||||
// The intent receiver
|
||||
voiXtremeReceiver = new VoiXtremeReceiver();
|
||||
voiXtremeReceiver.setDataManagers( mVxtPkgManager, mVxtCommandManager,mVxtTtsManager,mVxtAsrStateManager);
|
||||
voiXtremeReceiver.setIncomingHandler( mIncomingHandler );
|
||||
IntentFilter filter = new IntentFilter(VoiXtremeReceiver.BROADCAST_RECEIVE_INTENT_COMMAND);
|
||||
registerReceiver(voiXtremeReceiver, filter);
|
||||
|
||||
registerReceiver(new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, -1);
|
||||
|
||||
if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
|
||||
Log.d(TAG, "SCO - DISconnected");
|
||||
}
|
||||
|
||||
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
|
||||
Log.d(TAG, "SCO - connected");
|
||||
((AudioManager) getSystemService(Context.AUDIO_SERVICE)).setMode(AudioManager.MODE_IN_CALL);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}, new IntentFilter(AudioManager.ACTION_SCO_AUDIO_STATE_CHANGED));
|
||||
|
||||
|
||||
((AudioManager) getSystemService(Context.AUDIO_SERVICE)).setBluetoothScoOn(true);
|
||||
((AudioManager) getSystemService(Context.AUDIO_SERVICE)).startBluetoothSco();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Service Overrides / start command
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
return START_STICKY; // We want to live forever
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Service Overrides / destroy service
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
// Executed Sometimes, when Android OS decides to execute it or not.
|
||||
// GoodBye message:
|
||||
|
||||
unregisterReceiver(voiXtremeReceiver);
|
||||
// ttsEngine.speak(mGoodByeMessage, false, "GoodByeMessage");
|
||||
|
||||
ttsEngineFinalize();
|
||||
if (ttsEngine != null)
|
||||
ttsEngine.release();
|
||||
|
||||
ttsEngine = null;
|
||||
mVxtEngineApi = null;
|
||||
mVxtCommandManager = null;
|
||||
|
||||
mIsVoiceLoaded= false;
|
||||
mIsSepaking = false;
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// Voixtreme callbacks to implement tts features
|
||||
//=========================================================================
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to set the loaded ASR language
|
||||
public void ttsSetLanguage( String asrLanguageConfigured)
|
||||
{
|
||||
Log.i( TAG, "ttsSetLanguage LanguageConfigured=" + asrLanguageConfigured );
|
||||
mAsrLanguageConfigured= asrLanguageConfigured;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to initialize the tts vocalizer engine
|
||||
// and load the list of available voices
|
||||
// issued from VxtEngine Api when receivent an inializeAll intent
|
||||
public void ttsEngineIntialize(String voiceConfigured)
|
||||
{
|
||||
|
||||
Log.i( TAG, "ttsEngineIntialize VoiceConfigured=" + voiceConfigured );
|
||||
|
||||
mTtsCurParm.mVoiceConfigured= voiceConfigured;
|
||||
mTtsCurParm.mVolume = mTtsConst.DEFAULT_VOLUME;
|
||||
mTtsCurParm.mRate = mTtsConst.DEFAULT_RATE;
|
||||
mTtsCurParm.mPitch = mTtsConst.DEFAULT_PITCH;
|
||||
|
||||
|
||||
// Load the native vocalizer SO
|
||||
vocalizerLoadNativeLibraries();
|
||||
|
||||
// Load list of available voices
|
||||
vocalizerInitializeSpeechEngine();
|
||||
|
||||
// Once the speech engine is initialized, the voice list is aynchronously sent to emulator app
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to unload the voice
|
||||
// Warning the voice is NOT really unloaded ...
|
||||
public void ttsEngineUnloadVoice()
|
||||
{
|
||||
mIsVoiceLoaded= false;
|
||||
ttsEngine.stop();
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to load the tts vocalizer engine
|
||||
// issued from VxtEngine Api when receivent an inializeTts intent
|
||||
// using the configured voice
|
||||
public void ttsEngineLoadVoice(String voiceSelected)
|
||||
{
|
||||
|
||||
Log.i( TAG, "ttsEngineLoadVoice VoiceSelected=" + voiceSelected );
|
||||
|
||||
mTtsCurParm.mVoiceSelected = voiceSelected;
|
||||
|
||||
// Once the speech engine is initialized, and the vocie is selecterd by user,
|
||||
// the -selected- voice can be loaded
|
||||
vocalizerLoadVoiceAndConfigure();
|
||||
|
||||
// Also the rulset resources can be loaded
|
||||
vocalizerLoadRules();
|
||||
|
||||
// Say the (harcoded) welcome message with version
|
||||
mIsVoiceLoaded= true;
|
||||
mIsInitializeTts= true;
|
||||
ttsEngine.speak( "VoiXtreme version " + VOIXTREME_SERVICE_VERSION, false, "0");
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to terminate the tts vocalizer engine
|
||||
public void ttsEngineFinalize ()
|
||||
{
|
||||
|
||||
if( ttsEngine != null) {
|
||||
|
||||
if( mTtsCurParm.mRuleHandle != -1) {
|
||||
ttsEngine.unloadResource(mTtsCurParm.mRuleHandle);
|
||||
mTtsCurParm.mRuleHandle = -1;
|
||||
}
|
||||
|
||||
ttsEngine.release();
|
||||
ttsEngine= null;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to know if tts engine is currently speaking
|
||||
public boolean ttsEngineIsSpeaking()
|
||||
{
|
||||
return mIsSepaking;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// This method is called from Vxt to stop any currently speaking action
|
||||
public boolean ttsEngineStopSpeaking()
|
||||
{
|
||||
Log.i( TAG, "ttsEngineStopSpeaking" );
|
||||
|
||||
boolean isOk= ttsEngine.stop();
|
||||
if( isOk== false) {
|
||||
Log.e( TAG, "ttsEngineStopSpeaking ERROR" );
|
||||
}
|
||||
// No more values (disable callbacks)
|
||||
mSay.mSayTtsId = 0;
|
||||
mSay.mSayAsrMode = 0;
|
||||
mSay.mSayTtsMode = 0;
|
||||
mSay.mSayPhrase = "";
|
||||
|
||||
return isOk;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// say a phrase by vocalizer that runs it by his own thread
|
||||
public boolean ttsEngineSay( int ttsId, int asrMode, int ttsMode, String phrase, String commandId)
|
||||
{
|
||||
Log.i( TAG, "ttsEngineSay ='" + phrase + "' CmdId=" + commandId + "' TtsId=" + ttsId);
|
||||
|
||||
if( mIsSepaking== false) {
|
||||
|
||||
// We put the data on the shared object
|
||||
// The local message handler will put it on tts engine
|
||||
mVxtTtsManager.SetTtsValues( ttsId, asrMode, ttsMode, phrase, commandId);
|
||||
//mVxtCommandManager.SetTtsValues( ttsId, asrMode, ttsMode, phrase);
|
||||
mIncomingHandler.sendMessage( Message.obtain( mIncomingHandler, COMMAND_TTS));
|
||||
}
|
||||
else {
|
||||
// TODO ERROR
|
||||
Log.e( TAG,"ttsEngineSay ERROR ENGINE IS SPEAKING =" + phrase);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// Binder
|
||||
//=========================================================================
|
||||
|
||||
//=========================================================================
|
||||
// To comunicate with service from main activity
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// Vocalizer engine management
|
||||
//=========================================================================
|
||||
|
||||
//=========================================================================
|
||||
// Dynamically load the Nuance Vocalizer Expressive library at runtime
|
||||
// Mandatory to call before calling any native method.
|
||||
private void vocalizerLoadNativeLibraries()
|
||||
{
|
||||
System.loadLibrary("NuanceVocalizer");
|
||||
Log.i(TAG, "vocalizerLoadNativeLibraries libNuanceVocalizer.so loaded");
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
/**
|
||||
* Constructs and begins initialization of the Text-to-Speech engine.
|
||||
* This method will be called once during the life time of the service
|
||||
* The list of voices and names map is populated with existing ones
|
||||
*/
|
||||
private void vocalizerInitializeSpeechEngine() {
|
||||
// Check if we have a Text-to-Speech engine object from the last session (activity recreation).
|
||||
// because the service will be alive forever or starts when the device boot is completed and not controlled by user
|
||||
//ttsEngine=(VocalizerEngine)getLastNonConfigurationInstance();
|
||||
|
||||
Log.i(TAG, "vocalizerInitializeSpeechEngine Beg");
|
||||
|
||||
if (ttsEngine == null) {
|
||||
// Activity is first created, so create a new Text-to-Speech engine and configure it.
|
||||
|
||||
// Use the application context to prevent memory leaks when re-using the
|
||||
// Text-to-Speech engine accross activity recreations due to configuration
|
||||
// changes.
|
||||
ttsEngine = new VocalizerEngine(getApplicationContext());
|
||||
|
||||
// Register this service as the listener to receive state change events.
|
||||
ttsEngine.setListener(this);
|
||||
|
||||
// Begin the initialization of the Text-to-Speech engine. Note that the
|
||||
// initialization process is asynchronous. onStateChanged will be invoked
|
||||
// once the initialization process is completed.
|
||||
// //////////
|
||||
// Then an intent will be sent to parent with voice list
|
||||
ttsEngine.initialize();
|
||||
} else {
|
||||
// Send back by intent the configured language and (comma separated) voices list
|
||||
// As well as it was sent in initial load
|
||||
sendIntentInitializeAllResult( mAsrLanguageConfigured, mVoicesNames);
|
||||
}
|
||||
|
||||
Log.i(TAG, "vocalizerInitializeSpeechEngine End");
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// To populate mVoiceNamesListMap with all available voices within obb expansion file
|
||||
// build comma separated list of voices into mVoicesNames
|
||||
private void vocalizerLoadVoiceListMap( VocalizerVoice[] aVoicesList)
|
||||
{
|
||||
Log.i(TAG, "vocalizerLoadVoiceListMap");
|
||||
if (aVoicesList != null) {
|
||||
mVoicesNames="";
|
||||
mVoiceNamesListMap = new LinkedHashMap<String, VocalizerVoice>(); // LinkedHashMap preserves insertion order!
|
||||
for (int index = 0; index < aVoicesList.length; ++index) {
|
||||
String voiceName= aVoicesList[index].getVoiceName();
|
||||
mVoiceNamesListMap.put(voiceName, aVoicesList[index]);
|
||||
if( index == 0)
|
||||
mVoicesNames= mVoicesNames + voiceName;
|
||||
else
|
||||
mVoicesNames= mVoicesNames + "," + voiceName;
|
||||
Log.d(TAG, "Voice '" + voiceName + "' found");
|
||||
}
|
||||
Log.d(TAG, "Total voices: " + mVoiceNamesListMap.size());
|
||||
Log.d(TAG, "Voices List: " + mVoicesNames );
|
||||
Log.d(TAG, "VoiceSelector map initialized correctly!");
|
||||
} else {
|
||||
Log.e(TAG, "vocalizerLoadVoiceListMap Error, not available voices!");
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Returns null on error
|
||||
// mVoiceNamesListMap (vocalizerLoadVoiceListMap) MUST be called before
|
||||
// Returns the selected voice or the default one
|
||||
private VocalizerVoice vocalizerVoiceFromVoiceName(String sVoiceSelected, String sVoiceConfigured)
|
||||
{
|
||||
Log.i(TAG, "vocalizerVoiceFromVoiceName VoiceSelected=" + sVoiceSelected);
|
||||
|
||||
if( mVoiceNamesListMap == null) {
|
||||
Log.e(TAG, "vocalizerVoiceFromVoiceName FATAL ERROR NO LIST ");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Try to get the selected voice
|
||||
if( mVoiceNamesListMap.containsKey(sVoiceSelected)) {
|
||||
Log.i(TAG, "vocalizerVoiceFromVoiceName FOUND " + sVoiceSelected);
|
||||
return mVoiceNamesListMap.get(sVoiceSelected);
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "Error, the selected voice '" + sVoiceSelected + "' is not available!");
|
||||
if( mVoiceNamesListMap.containsKey(sVoiceConfigured)) {
|
||||
Log.i(TAG, "vocalizerVoiceFromVoiceName FOUND " + sVoiceConfigured);
|
||||
return mVoiceNamesListMap.get(sVoiceConfigured);
|
||||
}
|
||||
else {
|
||||
|
||||
Log.e(TAG, "Error, the configured voice '" + sVoiceConfigured + "' is not available!");
|
||||
Log.e(TAG, "Available voices are:");
|
||||
for (Map.Entry<String, VocalizerVoice> entry : mVoiceNamesListMap.entrySet()) {
|
||||
Log.e(TAG, "Key : " + entry.getKey() + " Value : " + entry.getValue());
|
||||
}
|
||||
// Select the first one
|
||||
String defaultVoice = (String) mVoiceNamesListMap.keySet().toArray()[0];
|
||||
Log.e(TAG, "Selected voice by default: " + defaultVoice);
|
||||
return mVoiceNamesListMap.get(defaultVoice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
/*
|
||||
* Load the Tts voice mVoiceSelected or mVoiceConfigured
|
||||
* Configure the speech properties ( mVolume, mRate, mPitch)
|
||||
* */
|
||||
private boolean vocalizerLoadVoiceAndConfigure()
|
||||
{
|
||||
Log.i(TAG, "vocalizerLoadVoiceAndConfigure " + mTtsCurParm.mVoiceSelected );
|
||||
|
||||
ttsEngine.setAudioStream( AudioManager.STREAM_VOICE_CALL);
|
||||
// Load the voice
|
||||
if( ttsEngine.loadVoice( vocalizerVoiceFromVoiceName( mTtsCurParm.mVoiceSelected, mTtsCurParm.mVoiceConfigured)) ) {
|
||||
// Set initial parameters
|
||||
vocalizerConfigureSpeechProperties( mTtsCurParm.mVolume, mTtsCurParm.mRate, mTtsCurParm.mPitch);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "vocalizerLoadVoiceAndConfigure UNABLE TO LOAD VOICE " + mTtsCurParm.mVoiceSelected );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
/*
|
||||
* Load the Tts rules _vxt_ttsrules.txt
|
||||
* */
|
||||
private boolean vocalizerLoadRules()
|
||||
{
|
||||
String rulesFileName= System.getenv("EXTERNAL_STORAGE") + "/voixtreme/_vxt_ttsrules.txt";
|
||||
|
||||
Log.i(TAG, "vocalizerLoadRules " + rulesFileName);
|
||||
|
||||
if( mTtsCurParm.mRuleHandle!= -1) {
|
||||
ttsEngine.unloadResource( mTtsCurParm.mRuleHandle);
|
||||
mTtsCurParm.mRuleHandle= -1;
|
||||
}
|
||||
|
||||
try {
|
||||
File ruleFile = new File(rulesFileName);
|
||||
int fileLen = (int) ruleFile.length();
|
||||
byte[] ruleData = new byte[fileLen];
|
||||
FileInputStream fis = new FileInputStream(ruleFile);
|
||||
fis.read(ruleData);
|
||||
mTtsCurParm.mRuleHandle= ttsEngine.loadRuleSet( ruleData);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.e(TAG, "vocalizerLoadRules UNABLE TO LOAD " + rulesFileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
/**
|
||||
* Updates the Text-to-Speech engine properties (volume, rate and pitch) with
|
||||
* the values currently selected in the UI. This method should be called whenever
|
||||
* the selection of any of the properties spinners is changed, or when a new
|
||||
* voice is loaded.
|
||||
* All the parameters are from 0 to 100 and rescaled to tts values
|
||||
*/
|
||||
private void vocalizerConfigureSpeechProperties(int voiceVolume, int voiceRate, int voicePitch )
|
||||
{
|
||||
|
||||
Log.i(TAG, "vocalizerConfigureSpeechProperties V=" + voiceVolume + " R=" + voiceRate + " P=" + voicePitch);
|
||||
|
||||
// Rescaling values:
|
||||
int rescaled;
|
||||
|
||||
// Volume
|
||||
float fRescaledVolume = (((voiceVolume * 1.0f)/mTtsConst.MAX_PROPERTY) * (mTtsConst.MAX_VOLUME - mTtsConst.MIN_VOLUME)) + mTtsConst.MIN_VOLUME;
|
||||
rescaled= Math.round(fRescaledVolume);
|
||||
Log.i(TAG, "Volume 0-100 Rescaled=" + rescaled );
|
||||
ttsEngine.setSpeechVolume(rescaled);
|
||||
|
||||
// Rate
|
||||
float fRescaledRate = (((voiceRate * 1.0f)/mTtsConst.MAX_PROPERTY) * (mTtsConst.MAX_RATE - mTtsConst.MIN_RATE)) + mTtsConst.MIN_RATE;
|
||||
rescaled= Math.round(fRescaledRate);
|
||||
Log.i(TAG, "Rate 50-400 Rescaled=" + rescaled );
|
||||
ttsEngine.setSpeechRate(rescaled);
|
||||
|
||||
// Pitch
|
||||
float fRescaledPitch = (((voicePitch * 1.0f)/mTtsConst.MAX_PROPERTY) * (mTtsConst.MAX_PITCH - mTtsConst.MIN_PITCH)) + mTtsConst.MIN_PITCH;
|
||||
rescaled= Math.round(fRescaledPitch);
|
||||
Log.i(TAG, "Pitch 50-200 Rescaled=" + rescaled );
|
||||
ttsEngine.setSpeechPitch(rescaled);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// parameter is from 0 to 100 and rescaled to tts values
|
||||
public void vocalizerConfigureVolume( int voiceVolume)
|
||||
{
|
||||
mTtsCurParm.mVolume= voiceVolume;
|
||||
Log.i(TAG, "vocalizerConfigureVolume 0-100 =" + voiceVolume );
|
||||
|
||||
if (mIsVoiceLoaded) {
|
||||
// Volume
|
||||
float fRescaledVolume = (((voiceVolume * 1.0f) / mTtsConst.MAX_PROPERTY) * (mTtsConst.MAX_VOLUME - mTtsConst.MIN_VOLUME)) + mTtsConst.MIN_VOLUME;
|
||||
int rescaled= Math.round(fRescaledVolume);
|
||||
Log.i(TAG, "vocalizerConfigureVolume 0-100 Rescaled=" + rescaled );
|
||||
ttsEngine.setSpeechVolume( rescaled);
|
||||
}else {
|
||||
Log.e(TAG, "vocalizerConfigureVolume 0-100 ERROR" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// parameter is from 0 to 100 and rescaled to tts values
|
||||
public void vocalizerConfigureRate( int voiceRate)
|
||||
{
|
||||
mTtsCurParm.mRate= voiceRate;
|
||||
Log.i(TAG, "vocalizerConfigureRate 0-100 =" + voiceRate );
|
||||
|
||||
if (mIsVoiceLoaded) {
|
||||
// Rate
|
||||
float fRescaledRate = (((voiceRate * 1.0f) / mTtsConst.MAX_PROPERTY) * (mTtsConst.MAX_RATE - mTtsConst.MIN_RATE)) + mTtsConst.MIN_RATE;
|
||||
int rescaled= Math.round(fRescaledRate);
|
||||
Log.i(TAG, "vocalizerConfigureRate 50-400 Rescaled=" + rescaled );
|
||||
ttsEngine.setSpeechRate(rescaled);
|
||||
}else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// parameter is from 0 to 100 and rescaled to tts values
|
||||
public void vocalizerConfigurePitch( int voicePitch)
|
||||
{
|
||||
mTtsCurParm.mPitch= voicePitch;
|
||||
Log.i(TAG, "vocalizerConfigurePitch =" + voicePitch );
|
||||
|
||||
if (mIsVoiceLoaded) {
|
||||
// Pitch
|
||||
float fRescaledPitch = (((voicePitch * 1.0f) / mTtsConst.MAX_PROPERTY) * (mTtsConst.MAX_PITCH - mTtsConst.MIN_PITCH)) + mTtsConst.MIN_PITCH;
|
||||
int rescaled= Math.round(fRescaledPitch);
|
||||
Log.i(TAG, "vocalizerConfigurePitch 50-200 Rescaled=" + rescaled );
|
||||
ttsEngine.setSpeechPitch(rescaled);
|
||||
}else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Implementation of VocalizerEngineListener interface:
|
||||
//=========================================================================
|
||||
|
||||
/**
|
||||
* This method will be called when the state of the Text-to-Speech engine changes.
|
||||
* The main purpose of this method is to update the contents of the UI according
|
||||
* to the current engine state.
|
||||
* <p>
|
||||
* Note that when the engine is done initializing the first voice in the list
|
||||
* will automatically be loaded by a call to loadSelectedVoice. It is not
|
||||
* the default behavior of the Text-to-Speech engine to load any voice upon
|
||||
* initialization.
|
||||
*/
|
||||
@Override
|
||||
public void onStateChanged(int newState) {
|
||||
String stateStr = "";
|
||||
|
||||
switch (newState) {
|
||||
|
||||
// The tts engine was correctly initialized, we can load the voice list and send
|
||||
// to the calibrate for user choice
|
||||
case VocalizerEngine.STATE_INITIALIZED:
|
||||
stateStr = getString(R.string.state_initialized);
|
||||
Log.i( TAG, "onStateChanged STATE_INITIALIZED");
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_INITIALIZED");
|
||||
vocalizerLoadVoiceListMap( ttsEngine.getVoiceList());
|
||||
mIsSepaking = false;
|
||||
mSay.mSayTtsId = 0;
|
||||
// Send back by intent the configured language and (comma separated) voices list
|
||||
sendIntentInitializeAllResult( mAsrLanguageConfigured, mVoicesNames);
|
||||
break;
|
||||
|
||||
case VocalizerEngine.STATE_INIT_ERROR: // Initialization has failed.
|
||||
stateStr = getString(R.string.state_init_error);
|
||||
Log.i( TAG, "onStateChanged STATE_INIT_ERROR");
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_INIT_ERROR");
|
||||
mIsVoiceLoaded= false;
|
||||
break;
|
||||
|
||||
case VocalizerEngine.STATE_READY:
|
||||
stateStr = getString(R.string.state_ready);
|
||||
Log.i( TAG, "onStateChanged STATE_READY TtsId=" + mSay.mSayTtsId + " CmdId=" + mSay.mSayCommandId);
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_READY TtsId=" + mSay.mSayTtsId+ " CmdId=" + mSay.mSayCommandId);
|
||||
mIsSepaking = false;
|
||||
// CALL THE TTS API INDICATING THE SPEECH IS FINISHED
|
||||
if( mSay.mSayTtsId == 0) {
|
||||
// Special case, welcome locution ends
|
||||
if( mIsInitializeTts ) {
|
||||
Log.e( TAG, "onStateChanged STATE_READY AFTER INITIALIZE TTS");
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_READY AFTER INITIALIZE TTS");
|
||||
sendIntentInitializeTtsResult();
|
||||
mIsInitializeTts= false;
|
||||
}
|
||||
else {
|
||||
Log.e( TAG, "onStateChanged STATE_READY NO SAY ID");
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_READY NO SAY ID");
|
||||
}
|
||||
} else {
|
||||
// Is TTS Only
|
||||
if( mSay.mSayAsrMode == 1) {
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_READY TTS ONLY");
|
||||
// ensure just ONE time by request
|
||||
if( mIsUniqueResponse) {
|
||||
mIsUniqueResponse= false;
|
||||
sendIntentRecognitionResult(0,"", mSay.mSayCommandId);
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_READY UniqueResponse");
|
||||
}
|
||||
else {
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_READY NOT UniqueResponse");
|
||||
}
|
||||
}
|
||||
mVxtEngineApi.TtsCallback( 2, mSay.mSayTtsId, mSay.mSayAsrMode, mSay.mSayTtsMode);
|
||||
mSay.mSayTtsId = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case VocalizerEngine.STATE_SPEAKING:
|
||||
stateStr = getString(R.string.state_speaking);
|
||||
Log.i( TAG, "onStateChanged STATE_SPEAKING");
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_SPEAKING");
|
||||
mIsSepaking = true;
|
||||
if( mSay.mSayTtsId == 0) {
|
||||
Log.e( TAG, "onStateChanged STATE_SPEAKING NO SAY ID");
|
||||
mVxtEngineApi.nativelog( 0, TAG, "onStateChanged STATE_SPEAKING NO SAY ID");
|
||||
} else {
|
||||
// CALL THE TTS API INDICATING THE SPEECH IS BEGINNING
|
||||
mVxtEngineApi.TtsCallback(1, mSay.mSayTtsId, mSay.mSayAsrMode, mSay.mSayTtsMode);
|
||||
}
|
||||
break;
|
||||
|
||||
case VocalizerEngine.STATE_PAUSED:
|
||||
stateStr = getString(R.string.state_paused);
|
||||
Log.i( TAG, "onStateChanged STATE_PAUSED");
|
||||
break;
|
||||
|
||||
case VocalizerEngine.STATE_UNINITIALIZED:
|
||||
stateStr = getString(R.string.state_uninitialized);
|
||||
Log.i( TAG, "onStateChanged STATE_UNINITIALIZED");
|
||||
break;
|
||||
|
||||
default:
|
||||
stateStr = "Unknown state!";
|
||||
Log.i( TAG, "onStateChanged UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
Log.i(TAG, stateStr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method will be called by the Text-to-Speech engine when
|
||||
* it begins speaking. Note that in order to be notified one must pass
|
||||
* a text id to the speak method.
|
||||
*/
|
||||
@Override
|
||||
public void onSpeakElementStarted(String id) {
|
||||
Log.v(TAG, "Started text with id: " + id);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called by the Text-to-Speech engine when
|
||||
* it has completed speaking the text. Note that in order to be notified
|
||||
* one must pass a text id to the speak method.
|
||||
*/
|
||||
@Override
|
||||
public void onSpeakElementCompleted(String id) {
|
||||
Log.v(TAG, "Completed text with id: " + id);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be called by the Text-to-Speech engine when the list
|
||||
* of available voices changes. This is due to a voice package being
|
||||
* installed or removed in the system.
|
||||
*/
|
||||
@Override
|
||||
public void onVoiceListChanged() {
|
||||
mVoicesAvailable = ttsEngine.getVoiceList();
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// send back by intent the init result to emulator COMMAND_INITIALIZE_ALL
|
||||
public boolean sendIntentInitializeAllResult( String configuredLanguage, String voiceList )
|
||||
{
|
||||
Log.i( TAG, "sendIntentInitializeResult Language=" + configuredLanguage + " Voices=" + voiceList + " To=" + mVxtPkgManager.intentPackage );
|
||||
|
||||
// send back by intent the initialize response to emulator (language and voices)
|
||||
Intent intent = new Intent(mVxtPkgManager.intentPackage);
|
||||
intent.putExtra(EXTRAS_COMMAND, COMMAND_INITIALIZE_ALL);
|
||||
intent.putExtra(EXTRAS_TEXT, configuredLanguage);
|
||||
intent.putExtra(EXTRAS_VOICES, voiceList);
|
||||
sendBroadcast(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// send back by intent the init result to emulator COMMAND_INITIALIZE_TTS
|
||||
public boolean sendIntentInitializeTtsResult( )
|
||||
{
|
||||
Log.i( TAG, "sendIntentInitializeTtsResult To=" + mVxtPkgManager.intentPackage );
|
||||
|
||||
// send back by intent the initialize response to emulator (language and voices)
|
||||
Intent intent = new Intent(mVxtPkgManager.intentPackage);
|
||||
intent.putExtra(EXTRAS_COMMAND, COMMAND_INITIALIZE_TTS);
|
||||
sendBroadcast(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// send back by intent the recognition result to emulator
|
||||
// The result cand be empty and the reliability=0 for ending tts only commands
|
||||
public boolean sendIntentRecognitionResult(int reliability, String result, String commandId )
|
||||
{
|
||||
Log.i( TAG, "sendIntentRecognitionResult =" + result + " CmdId=" + commandId + " To= " + mVxtPkgManager.intentPackage );
|
||||
|
||||
// send back by intent the recognition result to emulator
|
||||
//String action = "com.voixtreme.calibrate.RESPONSE";
|
||||
Intent intent = new Intent(mVxtPkgManager.intentPackage);
|
||||
intent.putExtra(EXTRAS_COMMAND, COMMAND_SPEECH);
|
||||
intent.putExtra(EXTRAS_TEXT, result);
|
||||
intent.putExtra(EXTRAS_RELIABILITY, reliability);
|
||||
intent.putExtra(EXTRAS_ID, commandId);
|
||||
sendBroadcast(intent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// send back by intent the ASR engine state (COMMAND_STATE=4) to emulator
|
||||
// asrState 0=NOListen 1=NOSpeech 2=BOS 3=EOR
|
||||
public void sendIntentAsrStateChanges( int asrState )
|
||||
{
|
||||
Log.i( TAG, "sendIntentAsrStateChanges =" + asrState + " To=" + mVxtAsrStateManager.intentPackage );
|
||||
|
||||
// send back by intent the recognition result to emulator
|
||||
Intent intent = new Intent( mVxtAsrStateManager.intentPackage);
|
||||
intent.putExtra(EXTRAS_COMMAND, COMMAND_STATE);
|
||||
intent.putExtra(EXTRAS_ASRSTATE, asrState);
|
||||
sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// Asynchronously process the
|
||||
// Handler, will receive the commands
|
||||
// * From the intents
|
||||
// * From The Vxt component
|
||||
//=========================================================================
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// This method is invoked when an intent from Tnx Emulator arrives with a command
|
||||
public void updateFromHandler( int command, int idx) {
|
||||
|
||||
Log.i( TAG, "updateFromHandler Thread=" + Thread.currentThread().getId());
|
||||
switch ( command) {
|
||||
// From intent
|
||||
case VoiXtremeReceiver.COMMAND_INITIALIZE_ALL:
|
||||
Log.i(TAG, "update COMMAND_INITIALIZE_ALL" );
|
||||
mVxtEngineApi.vxtInitialize();
|
||||
mVxtEngineApi.nativelog( 0, TAG, "updateFromHandler COMMAND_INITIALIZE_ALL");
|
||||
break;
|
||||
|
||||
// From intent
|
||||
case VoiXtremeReceiver.COMMAND_INITIALIZE_TTS:
|
||||
Log.i(TAG, "update COMMAND_INITIALIZE_TTS Voice=" + mVxtPkgManager.ttsVoice);
|
||||
mVxtEngineApi.nativelog( 0, TAG, "updateFromHandler COMMAND_INITIALIZE_TTS Voice="+ mVxtPkgManager.ttsVoice);
|
||||
mVxtEngineApi.TtsLoadVoice( mVxtPkgManager.ttsVoice);
|
||||
break;
|
||||
|
||||
// From intent
|
||||
case VoiXtremeReceiver.COMMAND_FINALIZE:
|
||||
Log.i(TAG, "update COMMAND_FINALIZE" );
|
||||
mVxtEngineApi.nativelog( 0, TAG, "updateFromHandler COMMAND_FINALIZE" );
|
||||
mVxtEngineApi.vxtFinalize();
|
||||
break;
|
||||
|
||||
// From intent
|
||||
case VoiXtremeReceiver.COMMAND_SPEECH:
|
||||
int iIdx=
|
||||
Log.i(TAG, "update COMMAND_SPEECH Text=" + mVxtCommandManager[idx].text + " CmdId=" + mVxtCommandManager[idx].commandId);
|
||||
mVxtEngineApi.nativelog( 0, TAG, "updateFromHandler COMMAND_SPEECH Commands="+ mVxtCommandManager[idx].text);
|
||||
mVxtEngineApi.nativecommand( mVxtCommandManager[idx].text, mVxtCommandManager[idx].commandId );
|
||||
break;
|
||||
|
||||
// From intent
|
||||
case VoiXtremeReceiver.COMMAND_STATE:
|
||||
Log.i(TAG, "update COMMAND_STATE Register " );
|
||||
mVxtEngineApi.nativelog( 0, TAG, "updateFromHandler COMMAND_STATE Register");
|
||||
mVxtEngineApi.nativeregasrevent( mVxtAsrStateManager.mRegisteredForState, mVxtAsrStateManager.mRegisteredEnergy );
|
||||
break;
|
||||
|
||||
// (From native) Make it run the TTS
|
||||
case COMMAND_TTS:
|
||||
Log.i(TAG, "update COMMAND_TTS Phrase=" + mVxtTtsManager.sayPhrase );
|
||||
mVxtEngineApi.nativelog( 0, TAG, "updateFromHandler COMMAND_TTS Phrase="+ mVxtTtsManager.sayPhrase
|
||||
+ " TtsId=" + mVxtTtsManager.sayTtsId + "CmdId=" + mVxtTtsManager.commadId);
|
||||
mSay.mSayTtsId = mVxtTtsManager.sayTtsId;
|
||||
mSay.mSayAsrMode = mVxtTtsManager.sayAsrMode;
|
||||
mSay.mSayTtsMode = mVxtTtsManager.sayTtsMode;
|
||||
mSay.mSayPhrase = mVxtTtsManager.sayPhrase;
|
||||
mSay.mSayCommandId= mVxtTtsManager.commadId;
|
||||
|
||||
String textId = Integer.toString(mSay.mSayTtsId);
|
||||
mIsUniqueResponse= true;
|
||||
ttsEngine.speak( mVxtTtsManager.sayPhrase, false, textId);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
public static class IncomingHandler extends Handler {
|
||||
private final WeakReference<VoiXtremeService> mService;
|
||||
|
||||
IncomingHandler(VoiXtremeService service) {
|
||||
|
||||
mService = new WeakReference<>(service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
|
||||
VoiXtremeService service = mService.get();
|
||||
if (service != null) {
|
||||
service.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// the command messages from emulator or Asr
|
||||
public void handleMessage(final Message msg) {
|
||||
|
||||
updateFromHandler( msg.what, msg.arg1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.voixtreme.vocalengine.service;
|
||||
|
||||
//=============================================================================
|
||||
|
||||
import static com.voixtreme.vocalengine.service.VxtPkgManager.BROADCAST_SEND_INTENT_COMMAND;
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_STATE;
|
||||
|
||||
/**
|
||||
* Created by c_zorrilla on 25/11/2016.
|
||||
* This class holds the ASR engine state
|
||||
*/
|
||||
|
||||
public class VxtAsrStateManager
|
||||
{
|
||||
|
||||
// The command is always COMMAND_STATE
|
||||
public static final int command= COMMAND_STATE;
|
||||
|
||||
// The package to send the response
|
||||
public String intentPackage= BROADCAST_SEND_INTENT_COMMAND;
|
||||
|
||||
// 0=NOL No Listen-red, 1=NOS (NO Speech), 2=BOS (Begin Of Speech), EOR=End Of Recognition-green.
|
||||
public int mState=0;
|
||||
|
||||
// The energy of input sound 0-100
|
||||
public int mEnergy=0;
|
||||
|
||||
// Id if this sequence (counter)
|
||||
public int mId=0;
|
||||
|
||||
public boolean mRegisteredForState= false;
|
||||
|
||||
public boolean mRegisteredEnergy= false;
|
||||
|
||||
//=========================================================================
|
||||
// to emulator or calibrate state
|
||||
public void setState( int state)
|
||||
{
|
||||
mState= state;
|
||||
++mId;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Set the registration state from intent intent.register
|
||||
public void setRegisterState(int register)
|
||||
{
|
||||
if( (register== 1) || (register== 3) )
|
||||
mRegisteredForState= true;
|
||||
else
|
||||
mRegisteredForState= false;
|
||||
|
||||
if( (register== 2) || (register== 3) )
|
||||
mRegisteredEnergy= true;
|
||||
else
|
||||
mRegisteredEnergy= false;
|
||||
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// For package
|
||||
public void setIntentPackage( String intentPackage_)
|
||||
{
|
||||
this.intentPackage= intentPackage_;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.voixtreme.vocalengine.service;
|
||||
|
||||
import java.util.Observable; // To allow to monitor by observers if the queue is empty or not.
|
||||
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_TTS;
|
||||
|
||||
//=============================================================================
|
||||
/**
|
||||
* Created by JMA + CZ 7-11-16.
|
||||
* This class holds
|
||||
* 1) the command sent by the Tnx Emulator to VoiXtreme
|
||||
* - Is modified by the intent
|
||||
* - Is consommed by the service
|
||||
* 2) the command sent by VxtEngine to TTS
|
||||
* - Is modified by the TtsEngine
|
||||
* - Is consommed by the service (tts)
|
||||
*/
|
||||
public class VxtCommandManager
|
||||
{
|
||||
|
||||
// Members set by the intent
|
||||
public String text;
|
||||
public String commandId;
|
||||
|
||||
//=========================================================================
|
||||
// For emulator commands (intent SPEECH)
|
||||
public void setCommand( String text_, String commandId_) {
|
||||
|
||||
this.text= text_;
|
||||
this.commandId= commandId_;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.voixtreme.vocalengine.service;
|
||||
|
||||
/**
|
||||
* Created by c_zorrilla on 20/01/2017.
|
||||
*/
|
||||
|
||||
public class VxtPkgManager {
|
||||
|
||||
public static final String BROADCAST_SEND_INTENT_COMMAND = "com.voixtreme.calibrate.RESPONSE";
|
||||
|
||||
// The package to send the response
|
||||
public String intentPackage= BROADCAST_SEND_INTENT_COMMAND;
|
||||
|
||||
public String ttsVoice; // List of voices, or selected voice..
|
||||
public String asrLanguage; // The configured ASR language
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// For package
|
||||
public void setIntentPackage( String intentPackage_)
|
||||
{
|
||||
this.intentPackage= intentPackage_;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// For emulator commands (intent InitializeALL)
|
||||
public void setLanguaqe( String asrLanguage_) {
|
||||
asrLanguage= asrLanguage_;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// For emulator commands (intent nitializeTTS)
|
||||
public void setVoice( String ttsVoice_) {
|
||||
ttsVoice= ttsVoice_;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.voixtreme.vocalengine.service;
|
||||
|
||||
import static com.voixtreme.vocalengine.receivers.VoiXtremeReceiver.COMMAND_TTS;
|
||||
|
||||
/**
|
||||
* Created by c_zorrilla on 25/11/2016.
|
||||
* This class will hold the TTS data to / from vocalizer <=> TtsEngineApi (native)
|
||||
* Only for internal dispatch message handlers (NOT for intents)
|
||||
*/
|
||||
|
||||
public class VxtTtsManager
|
||||
{
|
||||
|
||||
// The command is always COMMAND_TTS
|
||||
public static final int command= COMMAND_TTS;
|
||||
|
||||
// The values for a TTS say
|
||||
public int sayTtsId=0;
|
||||
public int sayAsrMode=0;
|
||||
public int sayTtsMode=0;
|
||||
public String sayPhrase="";
|
||||
public String commadId="";
|
||||
|
||||
//=========================================================================
|
||||
// For Tts Values (TtsEngine)
|
||||
public void SetTtsValues( int sayTtsId_, int sayAsrMode_, int sayTtsMode_, String sayPhrase_, String commadId_)
|
||||
{
|
||||
sayTtsId= sayTtsId_;
|
||||
sayAsrMode= sayAsrMode_;
|
||||
sayTtsMode= sayTtsMode_;
|
||||
sayPhrase= sayPhrase_;
|
||||
commadId= commadId_;
|
||||
}
|
||||
|
||||
}
|
||||
188
app/src/main/java/com/voixtreme/vxtenginejni/TtsEngineApi.java
Normal file
188
app/src/main/java/com/voixtreme/vxtenginejni/TtsEngineApi.java
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
// This class is managed in the AndroidStudio environment
|
||||
|
||||
package com.voixtreme.vxtenginejni;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.voixtreme.vocalengine.service.VoiXtremeService;
|
||||
|
||||
//=============================================================================================
|
||||
// This class is the parent of the VxtEngineApi
|
||||
// Will expose the functions to manage the TTS engine from the VxtApi
|
||||
class TtsEngineApi
|
||||
{
|
||||
|
||||
// Tag
|
||||
private static final String TAG = TtsEngineApi.class.getSimpleName();
|
||||
|
||||
protected VoiXtremeService mService;
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
public TtsEngineApi(VoiXtremeService service) {
|
||||
|
||||
Log.i(TAG, "Constructor with service");
|
||||
mService = service;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// 0 Set the language of ASR Engine from initializeAll intent
|
||||
protected boolean TtsSetLanguage( String languageConfigured)
|
||||
{
|
||||
Log.i(TAG, "TtsSetLanguage LanguageConfigured=" + languageConfigured);
|
||||
|
||||
mService.ttsSetLanguage( languageConfigured);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// 1 Initialize The TTs Engine from initializeAll intent
|
||||
protected boolean TtsInitialize( String voiceConfigured)
|
||||
{
|
||||
Log.i(TAG, "TtsInitialize VoiceConfigured=" + voiceConfigured);
|
||||
// TODO check if already
|
||||
mService.ttsEngineIntialize( voiceConfigured);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Load the selected voice from initializeTts intent
|
||||
public boolean TtsLoadVoice( String voiceSelected)
|
||||
{
|
||||
Log.i(TAG, "TtsLoadVoice VoiceSelected=" + voiceSelected);
|
||||
mService.ttsEngineLoadVoice( voiceSelected);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 2 Finalize The TTs Engine
|
||||
protected boolean TtsFinalize()
|
||||
{
|
||||
Log.i(TAG, "TtsFinalize" );
|
||||
mService.ttsEngineFinalize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// 3 The TTS State
|
||||
public boolean TtsIsSpeaking( )
|
||||
{
|
||||
return mService.ttsEngineIsSpeaking();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// 4=StopSpeaking (while speaking ...)
|
||||
public boolean TtsStopSpeaking( )
|
||||
{
|
||||
Log.i(TAG, "TtsStopSpeaking" );
|
||||
return mService.ttsEngineStopSpeaking();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// say a phrase, call the service say method
|
||||
protected boolean TtsSay( int id, int asrMode, int ttsMode, String phraseToSay, String comandId)
|
||||
{
|
||||
|
||||
if( mService.ttsEngineIsSpeaking()== false) {
|
||||
mService.ttsEngineSay(id, asrMode, ttsMode, phraseToSay, comandId);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "TtsSay say while speaking WAITING Phrase=" + phraseToSay);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch(InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
if( mService.ttsEngineIsSpeaking()== false) {
|
||||
mService.ttsEngineSay(id, asrMode, ttsMode, phraseToSay, comandId);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "TtsSay ERROR, say while speaking Phrase=" + phraseToSay);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// Phrase processing should be overwrite by child class
|
||||
// 1=Speech begins, 2=Speech ends
|
||||
// TODO improve this
|
||||
public boolean TtsCallback( int action, int id, int asrMode, int ttsMode)
|
||||
{
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Set the TTS engine property
|
||||
protected boolean TtsSetVolume( int voiceVolume)
|
||||
{
|
||||
|
||||
Log.i(TAG, "TtsSetVolume =" + voiceVolume );
|
||||
mService.vocalizerConfigureVolume( voiceVolume);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Set the TTS engine property
|
||||
protected boolean TtsSetRate( int voiceRate)
|
||||
{
|
||||
|
||||
Log.i(TAG, "TtsSetRate =" + voiceRate );
|
||||
mService.vocalizerConfigureRate( voiceRate);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Set the TTS engine property
|
||||
protected boolean TtsSetPitch( int voicePitch)
|
||||
{
|
||||
|
||||
Log.i(TAG, "TtsSetPitch =" + voicePitch );
|
||||
mService.vocalizerConfigurePitch( voicePitch);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// an ASR is finished, send back to emulator the result through the service
|
||||
protected boolean onRecognitionFinished( int reliability, String result, String commandId)
|
||||
{
|
||||
|
||||
Log.i(TAG, "onRecognitionFinished reliability=" + reliability + " Result=" + result);
|
||||
mService.sendIntentRecognitionResult( reliability, result, commandId );
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// The ASR recognizer engine state has changes, send back to emulator the current state through the service
|
||||
protected void onAsrStateChanges( int asrState)
|
||||
{
|
||||
Log.i(TAG, "onAsrStateChanges State=" + asrState);
|
||||
mService.sendIntentAsrStateChanges(asrState);
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// An Asr state event should be sent backward to APP through onAsrStateChanges
|
||||
// 0=State 1=Energy
|
||||
public boolean onAsrEvent( int event, int value )
|
||||
{
|
||||
if( event == 0)
|
||||
onAsrStateChanges( value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
398
app/src/main/java/com/voixtreme/vxtenginejni/VxtEngineApi.java
Normal file
398
app/src/main/java/com/voixtreme/vxtenginejni/VxtEngineApi.java
Normal file
|
|
@ -0,0 +1,398 @@
|
|||
|
||||
// This class is mantained in the VisaulStudio2015 environment and copied to the AS prpject
|
||||
// Version V4.11.004
|
||||
|
||||
package com.voixtreme.vxtenginejni;
|
||||
|
||||
// Comment / uncomment
|
||||
import com.voixtreme.vocalengine.service.VoiXtremeService;
|
||||
import com.voixtreme.vxtenginejni.TtsEngineApi;
|
||||
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.MediaPlayer.OnCompletionListener;
|
||||
|
||||
public class VxtEngineApi extends TtsEngineApi
|
||||
{
|
||||
|
||||
|
||||
// The constructor should be renamed in each environment
|
||||
// Comment / uncomment the proper constructor
|
||||
//
|
||||
// Constructor for real AS project
|
||||
public VxtEngineApi(VoiXtremeService service) {
|
||||
//
|
||||
// Constructor for testing VS2015 project
|
||||
//public VxtEngineApi( int service) {
|
||||
super(service);
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
// Private members
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
|
||||
static private VxtEngineApi mTheInstance = null;
|
||||
|
||||
private MediaPlayer mMp[]= new MediaPlayer[3];
|
||||
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
// Public methods
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
|
||||
//=============================================================================================
|
||||
// Java to C callback (public)
|
||||
//=============================================================================================
|
||||
|
||||
//=============================================================================================
|
||||
// Phrase processing (override of TtsEngineApi)
|
||||
// 1=Speech begins, 2=Speech ends
|
||||
@Override
|
||||
public boolean TtsCallback( int action, int id, int asrMode, int ttsMode)
|
||||
{
|
||||
// call the native function TtsCallback
|
||||
nativettscallback( action, id, asrMode, ttsMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// non native CALLS (public)
|
||||
//=============================================================================================
|
||||
|
||||
//=============================================================================================
|
||||
// Initialize jni and voixtreme
|
||||
// reads the confguration file , get the default configuration values
|
||||
// Returs the list of available vocies in TTS
|
||||
public boolean vxtInitialize()
|
||||
{
|
||||
mTheInstance = this;
|
||||
|
||||
InitializeAsr();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Just test
|
||||
public boolean vxtTest()
|
||||
{
|
||||
mTheInstance = this;
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Finalize jni and voixtreme
|
||||
public boolean vxtFinalize()
|
||||
{
|
||||
nativefinalize();
|
||||
|
||||
// release all allocated MP
|
||||
for( int i=0; i<3; ++i) {
|
||||
if( mMp[i]!= null) {
|
||||
mMp[i].release();
|
||||
mMp[i] = null;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Perform a native command from intent or TCP/IP
|
||||
// This is the tagged command string "<TTS>xxxx"
|
||||
public boolean vxtCommand( String voiceCommand, String commandId)
|
||||
{
|
||||
return nativecommand( voiceCommand, commandId );
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
// Private functions
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
|
||||
//=============================================================================================
|
||||
// Initialize ASR jni
|
||||
// reads the confguration file , get the default configuration values
|
||||
// Returs the list of available vocies in TTS
|
||||
private boolean InitializeAsr()
|
||||
{
|
||||
System.loadLibrary("vocon3200_platform");
|
||||
System.loadLibrary("vocon3200_base");
|
||||
System.loadLibrary("genericdca");
|
||||
System.loadLibrary("vocon3200_asr");
|
||||
System.loadLibrary("vocon3200_pron");
|
||||
System.loadLibrary("vocon3200_sem");
|
||||
System.loadLibrary("vocon3200_sem3");
|
||||
System.loadLibrary("vocon3200_gram2");
|
||||
System.loadLibrary("pal_core");
|
||||
System.loadLibrary("pal_audio");
|
||||
System.loadLibrary("vocon_ext_stream");
|
||||
System.loadLibrary("vocon_ext_heap");
|
||||
System.loadLibrary("asr-jni");
|
||||
|
||||
// TODO, get the real serail number of the unit
|
||||
String serialNumber="1234567890";
|
||||
String rootDirectory= System.getenv("EXTERNAL_STORAGE");
|
||||
nativeinitializeasr( rootDirectory, serialNumber);
|
||||
|
||||
nativelog( 0, "VxtEngineApi::InitializeAsr", "Serial=" + serialNumber);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// Play a beep
|
||||
private void playBeep(String audioFile)
|
||||
{
|
||||
final String myFinalAudio = audioFile;
|
||||
new Thread() {
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
MediaPlayer mp = new MediaPlayer();
|
||||
mp.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
|
||||
mp.setDataSource(myFinalAudio);
|
||||
mp.prepare();
|
||||
mp.start();
|
||||
|
||||
mp.setOnCompletionListener(new OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mp) {
|
||||
mp.release();
|
||||
mp = null;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) { }
|
||||
;}
|
||||
}.start();
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Play a beep
|
||||
private void playBeepStdGo( int beepIndex)
|
||||
{
|
||||
if( beepIndex > 2)
|
||||
return;
|
||||
final int beepIndexFinal= beepIndex;
|
||||
if( mMp[ beepIndex]!= null) {
|
||||
new Thread() {
|
||||
private final int beepIndex_ = beepIndexFinal;
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
mMp[ beepIndex_].start();
|
||||
} catch (Exception e) { }
|
||||
;}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Play a beep
|
||||
private void playBeepStdInit( String audioFile, int beepIndex)
|
||||
{
|
||||
if( beepIndex > 2)
|
||||
return;
|
||||
final String audioFile_ = audioFile;
|
||||
if( mMp[ beepIndex]== null) {
|
||||
try {
|
||||
mMp[ beepIndex]= new MediaPlayer();
|
||||
mMp[ beepIndex].setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
|
||||
mMp[ beepIndex].setDataSource(audioFile_);
|
||||
mMp[ beepIndex].prepare();
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// native CALLS (public)
|
||||
//=============================================================================================
|
||||
|
||||
/* A native method that is implemented by the
|
||||
* 'asr-jni' native library, which is packaged
|
||||
* with this application.
|
||||
*/
|
||||
public native String nativestringFromJNI( int step);
|
||||
|
||||
// ONLY FOR TESTS get the asr result
|
||||
public native String nativegetresult();
|
||||
|
||||
// Native to run threaded ASR in a loop TEST ONLY
|
||||
public native int nativeasr();
|
||||
|
||||
// Native to perform voice input called by vxtCommand
|
||||
public native boolean nativecommand( String voiceCommand, String commandId);
|
||||
|
||||
// Called by tts engine when a TTS event occurs
|
||||
// 1=Speech begins, 2=Speech ends
|
||||
public native void nativettscallback( int action, int id, int asr, int tts);
|
||||
|
||||
// Call this method to register the application about ASR events (state, energy)
|
||||
public native void nativeregasrevent( boolean eventState, boolean eventEnergy);
|
||||
|
||||
// Call this method to perform a log in the VoiXtreme file
|
||||
public native void nativelog( int type, String tag, String message);
|
||||
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
// CALLBACKS FROM NATIVE
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
|
||||
//=============================================================================================
|
||||
public static boolean from_native_recogfinished( int reliability, String result)
|
||||
{
|
||||
if (null != mTheInstance)
|
||||
{
|
||||
String cmdId="";
|
||||
mTheInstance.onRecognitionFinished( reliability, result, cmdId);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
public static boolean from_native_print(String scText)
|
||||
{
|
||||
// Log.i(TAG, "In MainActivity.print()! "+s.length);
|
||||
if (null != mTheInstance)
|
||||
{
|
||||
// theInstance.print(new String(s));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// to perform a beep by Java
|
||||
public static boolean from_native_playbeep(String scBeepFullPath)
|
||||
{
|
||||
if (null != mTheInstance)
|
||||
{
|
||||
mTheInstance.playBeep( scBeepFullPath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// to initialize a standard beep by Java
|
||||
public static boolean from_native_playbeep_std_init(String scBeepFullPath, int beepindex)
|
||||
{
|
||||
if( null != mTheInstance)
|
||||
{
|
||||
mTheInstance.playBeepStdInit( scBeepFullPath, beepindex);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// to perform a standard beep by Java (by index)
|
||||
public static boolean from_native_playbeep_std_go( int beepindex)
|
||||
{
|
||||
if( null != mTheInstance)
|
||||
{
|
||||
mTheInstance.playBeepStdGo( beepindex);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// to send an intent about ASR engine state
|
||||
public static boolean from_native_asrevent(int event, int value)
|
||||
{
|
||||
if (null != mTheInstance)
|
||||
{
|
||||
// here call the method
|
||||
mTheInstance.onAsrEvent( event, value );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Call the parent function in Tts
|
||||
// asrMode is ListenOnTts, Nested, TtsOnAsr
|
||||
// ttsMode is break or append
|
||||
public static boolean from_native_say( int iId, int asrMode, int ttsMode, String phraseToSay, String commandId)
|
||||
{
|
||||
if( null != mTheInstance)
|
||||
{
|
||||
// connected to TTS JAVA parent class
|
||||
return mTheInstance.TtsSay( iId, asrMode, ttsMode, phraseToSay, commandId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================================
|
||||
// Call the parent function in Tts
|
||||
// 0=Keep ASR language configured and default configured voice
|
||||
// 1=Initialize tts with selected voice
|
||||
// 2=Finalize Tts
|
||||
// 3=isSpeaking
|
||||
// 4=StopSpeaking
|
||||
// 5=Set volume
|
||||
// 6=Set rate
|
||||
// 7=set pitch
|
||||
public static boolean from_native_tts_engine_cmd( int action, int iParam, String sParam)
|
||||
{
|
||||
if (null != mTheInstance)
|
||||
{
|
||||
boolean bRes= false;
|
||||
// 0=Keep ASR language configured (this command should send an intent with voice list)
|
||||
if( action == 0)
|
||||
bRes= mTheInstance.TtsSetLanguage( sParam);
|
||||
// 1=Initialize tts with selected voice
|
||||
if( action == 1)
|
||||
bRes= mTheInstance.TtsInitialize( sParam);
|
||||
// 2=Finalize Tts
|
||||
if( action == 2)
|
||||
bRes= mTheInstance.TtsFinalize();
|
||||
// 3=isSpeaking
|
||||
if( action == 3)
|
||||
bRes= mTheInstance.TtsIsSpeaking();
|
||||
// 4=StopSpeaking
|
||||
if( action == 4)
|
||||
bRes= mTheInstance.TtsStopSpeaking();
|
||||
// 5=Set volume
|
||||
if( action == 5)
|
||||
bRes= mTheInstance.TtsSetVolume( iParam);
|
||||
// 6=Set rate
|
||||
if( action == 6)
|
||||
bRes= mTheInstance.TtsSetRate( iParam);
|
||||
// 7=set pitch
|
||||
if( action == 7)
|
||||
bRes= mTheInstance.TtsSetPitch( iParam);
|
||||
|
||||
|
||||
return bRes;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
//=============================================================================================
|
||||
// native CALLS (private)
|
||||
//============================================================================================= //---------------------------------------------------------------------------
|
||||
//=============================================================================================
|
||||
|
||||
// Init the native lib with root storage path
|
||||
private native void nativeinitializeasr( String fullPath, String serialNumber );
|
||||
|
||||
// Finalize the ASR
|
||||
private native void nativefinalize();
|
||||
|
||||
}
|
||||
BIN
app/src/main/jniLibs/armeabi-v7a/libNuanceVocalizer.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libNuanceVocalizer.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libasr-jni.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libasr-jni.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libgenericdca.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libgenericdca.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libpal_audio.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libpal_audio.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libpal_core.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libpal_core.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_asr.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_asr.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_base.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_base.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_gram2.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_gram2.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_platform.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_platform.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_pron.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_pron.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_sem.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_sem.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_sem3.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon3200_sem3.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_asr2sem.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_asr2sem.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_audioin.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_audioin.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_heap.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_heap.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_stream.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libvocon_ext_stream.so
Normal file
Binary file not shown.
16
app/src/main/res/layout/activity_main.xml
Normal file
16
app/src/main/res/layout/activity_main.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="com.tellnext.voxprinter.com.voixtreme.voxprinter.MainActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!" />
|
||||
</RelativeLayout>
|
||||
BIN
app/src/main/res/mipmap-hdpi/Thumbs.db
Normal file
BIN
app/src/main/res/mipmap-hdpi/Thumbs.db
Normal file
Binary file not shown.
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/Thumbs.db
Normal file
BIN
app/src/main/res/mipmap-mdpi/Thumbs.db
Normal file
Binary file not shown.
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-xhdpi/Thumbs.db
Normal file
BIN
app/src/main/res/mipmap-xhdpi/Thumbs.db
Normal file
Binary file not shown.
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/Thumbs.db
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/Thumbs.db
Normal file
Binary file not shown.
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/Thumbs.db
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/Thumbs.db
Normal file
Binary file not shown.
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
||||
2
app/src/main/res/values/colors.xml
Normal file
2
app/src/main/res/values/colors.xml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources></resources>
|
||||
5
app/src/main/res/values/dimens.xml
Normal file
5
app/src/main/res/values/dimens.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
</resources>
|
||||
14
app/src/main/res/values/strings.xml
Normal file
14
app/src/main/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<resources>
|
||||
<string name="app_name">VoiXtreme</string>
|
||||
|
||||
<string name="state_initialized">Engine initialized</string>
|
||||
<string name="state_ready">Engine is ready</string>
|
||||
<string name="state_speaking">Engine is speaking</string>
|
||||
<string name="state_paused">Engine is paused</string>
|
||||
<string name="state_uninitialized">Engine is uninitialized</string>
|
||||
<string name="state_init_error">Engine is in init error</string>
|
||||
<string name="need_permissions">You need to accept all permissions or the application cannot function correctly, terminating.</string>
|
||||
|
||||
|
||||
<string name="BootReceiver">VoxPrinter boot Receiver</string>
|
||||
</resources>
|
||||
20
app/src/main/res/values/styles.xml
Normal file
20
app/src/main/res/values/styles.xml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<!--<item name="colorPrimary">@color/colorPrimary</item>-->
|
||||
<!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
|
||||
<!--<item name="colorAccent">@color/colorAccent</item>-->
|
||||
</style>
|
||||
|
||||
<style name="Transparent" parent="android:Theme.Light.NoTitleBar">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<item name="android:backgroundDimEnabled">false</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.voixtreme.vocalengine;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* To work on unit tests, switch the Test Artifact in the Build Variants view.
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() throws Exception {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
23
build.gradle
Normal file
23
build.gradle
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.3.1'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
18
gradle.properties
Normal file
18
gradle.properties
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Project-wide Gradle settings.
|
||||
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
||||
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#Tue Apr 11 17:54:32 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
160
gradlew
vendored
Normal file
160
gradlew
vendored
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
90
gradlew.bat
vendored
Normal file
90
gradlew.bat
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
|
|
@ -0,0 +1 @@
|
|||
include ':app'
|
||||
Loading…
Add table
Add a link
Reference in a new issue