You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Add audio/general/text_to_speech project setting to enable/disable TTS.
This commit is contained in:
@@ -274,7 +274,9 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
||||
// ...add to FrameLayout
|
||||
containerLayout.addView(editText);
|
||||
|
||||
if (!GodotLib.setup(command_line)) {
|
||||
tts = new GodotTTS(activity);
|
||||
|
||||
if (!GodotLib.setup(command_line, tts)) {
|
||||
Log.e(TAG, "Unable to setup the Godot engine! Aborting...");
|
||||
alert(R.string.error_engine_setup_message, R.string.text_error_title, this::forceQuit);
|
||||
return false;
|
||||
@@ -574,7 +576,6 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
||||
final Activity activity = getActivity();
|
||||
io = new GodotIO(activity);
|
||||
netUtils = new GodotNetUtils(activity);
|
||||
tts = new GodotTTS(activity);
|
||||
Context context = getContext();
|
||||
directoryAccessHandler = new DirectoryAccessHandler(context);
|
||||
FileAccessHandler fileAccessHandler = new FileAccessHandler(context);
|
||||
@@ -591,8 +592,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC
|
||||
netUtils,
|
||||
directoryAccessHandler,
|
||||
fileAccessHandler,
|
||||
use_apk_expansion,
|
||||
tts);
|
||||
use_apk_expansion);
|
||||
|
||||
result_callback = null;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ public class GodotLib {
|
||||
GodotNetUtils netUtils,
|
||||
DirectoryAccessHandler directoryAccessHandler,
|
||||
FileAccessHandler fileAccessHandler,
|
||||
boolean use_apk_expansion,
|
||||
GodotTTS tts);
|
||||
boolean use_apk_expansion);
|
||||
|
||||
/**
|
||||
* Invoked on the main thread to clean up Godot native layer.
|
||||
@@ -74,7 +73,7 @@ public class GodotLib {
|
||||
* Invoked on the GL thread to complete setup for the Godot native layer logic.
|
||||
* @param p_cmdline Command line arguments used to configure Godot native layer components.
|
||||
*/
|
||||
public static native boolean setup(String[] p_cmdline);
|
||||
public static native boolean setup(String[] p_cmdline, GodotTTS tts);
|
||||
|
||||
/**
|
||||
* Invoked on the GL thread when the underlying Android surface has changed size.
|
||||
|
||||
@@ -62,8 +62,9 @@ public class GodotTTS extends UtteranceProgressListener {
|
||||
final private static int EVENT_CANCEL = 2;
|
||||
final private static int EVENT_BOUNDARY = 3;
|
||||
|
||||
final private TextToSpeech synth;
|
||||
final private LinkedList<GodotUtterance> queue;
|
||||
final private Activity activity;
|
||||
private TextToSpeech synth;
|
||||
private LinkedList<GodotUtterance> queue;
|
||||
final private Object lock = new Object();
|
||||
private GodotUtterance lastUtterance;
|
||||
|
||||
@@ -71,10 +72,7 @@ public class GodotTTS extends UtteranceProgressListener {
|
||||
private boolean paused;
|
||||
|
||||
public GodotTTS(Activity p_activity) {
|
||||
synth = new TextToSpeech(p_activity, null);
|
||||
queue = new LinkedList<GodotUtterance>();
|
||||
|
||||
synth.setOnUtteranceProgressListener(this);
|
||||
activity = p_activity;
|
||||
}
|
||||
|
||||
private void updateTTS() {
|
||||
@@ -186,6 +184,16 @@ public class GodotTTS extends UtteranceProgressListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize synth and query.
|
||||
*/
|
||||
public void init() {
|
||||
synth = new TextToSpeech(activity, null);
|
||||
queue = new LinkedList<GodotUtterance>();
|
||||
|
||||
synth.setOnUtteranceProgressListener(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an utterance to the queue.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user