Changes necessary to get working on Android.

This commit is contained in:
Nolan Darilek 2020-08-18 17:23:05 -05:00
parent c5f8e28028
commit f0834feea5
4 changed files with 6 additions and 12 deletions

4
TTS.gd
View File

@ -10,8 +10,8 @@ signal done
func _init():
if OS.get_name() == "Server" or OS.has_feature("JavaScript"):
return
elif Engine.has_singleton("AndroidTTS"):
tts = Engine.get_singleton("AndroidTTS")
elif Engine.has_singleton("GodotTTS"):
tts = Engine.get_singleton("GodotTTS")
else:
TTS = preload("godot-tts.gdns")
if TTS and (TTS.can_instance() or Engine.editor_hint):

View File

@ -23,7 +23,7 @@ android {
buildToolsVersion "29.0.3"
defaultConfig {
minSdkVersion 18
minSdkVersion 21
targetSdkVersion 29
versionCode pluginVersionCode
versionName pluginVersionName

View File

@ -3,6 +3,3 @@
name="GodotTTS"
binary_type="local"
binary="godot-tts.aar"
[dependencies]
remote=[]

View File

@ -1,14 +1,12 @@
package games.lightsout.godot.tts;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.godotengine.godot.Godot;
import org.godotengine.godot.plugin.GodotPlugin;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.content.Context;
import android.speech.tts.TextToSpeech;
import android.view.accessibility.AccessibilityManager;
@ -18,15 +16,14 @@ public class TTS extends GodotPlugin implements TextToSpeech.OnInitListener {
private float rate = 1f;
// private Integer utteranceId = 0;
private Integer utteranceId = 0;
public void speak(String text, boolean interrupt) {
int mode = TextToSpeech.QUEUE_ADD;
if (interrupt)
mode = TextToSpeech.QUEUE_FLUSH;
HashMap<String, String> params = new HashMap();
tts.speak(text, mode, params);
// this.utteranceId++;
tts.speak(text, mode, null, this.utteranceId.toString());
this.utteranceId++;
}
public void stop() {