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(): func _init():
if OS.get_name() == "Server" or OS.has_feature("JavaScript"): if OS.get_name() == "Server" or OS.has_feature("JavaScript"):
return return
elif Engine.has_singleton("AndroidTTS"): elif Engine.has_singleton("GodotTTS"):
tts = Engine.get_singleton("AndroidTTS") tts = Engine.get_singleton("GodotTTS")
else: else:
TTS = preload("godot-tts.gdns") TTS = preload("godot-tts.gdns")
if TTS and (TTS.can_instance() or Engine.editor_hint): if TTS and (TTS.can_instance() or Engine.editor_hint):

View File

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

View File

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

View File

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