mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-11-22 14:05:56 +00:00
Experimental untested support for setting speech rate on Android.
This commit is contained in:
parent
f58f309d0c
commit
691dd66054
2
TTS.gd
2
TTS.gd
|
@ -70,7 +70,7 @@ func stop():
|
||||||
|
|
||||||
func get_is_rate_supported():
|
func get_is_rate_supported():
|
||||||
if Engine.get_singleton("AndroidTTS"):
|
if Engine.get_singleton("AndroidTTS"):
|
||||||
return false
|
return true
|
||||||
elif OS.has_feature('JavaScript'):
|
elif OS.has_feature('JavaScript'):
|
||||||
return true
|
return true
|
||||||
elif tts != null:
|
elif tts != null:
|
||||||
|
|
|
@ -32,8 +32,20 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe
|
||||||
tts.stop();
|
tts.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void set_rate(Float rate) {
|
||||||
|
Float newRate;
|
||||||
|
if (rate <= 50)
|
||||||
|
newRate = rate / 50;
|
||||||
|
else {
|
||||||
|
newRate = rate - 50;
|
||||||
|
newRate = 1 + (newRate / 5);
|
||||||
|
}
|
||||||
|
tts.setSpeechRate(newRate);
|
||||||
|
}
|
||||||
|
|
||||||
public void getInstanceId(int pInstanceId) {
|
public void getInstanceId(int pInstanceId) {
|
||||||
// You will need to call this method from Godot and pass in the get_instance_id().
|
// You will need to call this method from Godot and pass in the
|
||||||
|
// get_instance_id().
|
||||||
instanceId = pInstanceId;
|
instanceId = pInstanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,17 +54,12 @@ public class TTS extends Godot.SingletonBase implements TextToSpeech.OnInitListe
|
||||||
}
|
}
|
||||||
|
|
||||||
public TTS(Activity p_activity) {
|
public TTS(Activity p_activity) {
|
||||||
this.activity = (Godot)p_activity;
|
this.activity = (Godot) p_activity;
|
||||||
this.appActivity = p_activity;
|
this.appActivity = p_activity;
|
||||||
this.appContext = appActivity.getApplicationContext();
|
this.appContext = appActivity.getApplicationContext();
|
||||||
this.tts = new TextToSpeech(this.appContext, this);
|
this.tts = new TextToSpeech(this.appContext, this);
|
||||||
// Register class name and functions to bind.
|
// Register class name and functions to bind.
|
||||||
registerClass("AndroidTTS", new String[]
|
registerClass("AndroidTTS", new String[] { "speak", "stop", "set_rate", "getInstanceId" });
|
||||||
{
|
|
||||||
"speak",
|
|
||||||
"stop",
|
|
||||||
"getInstanceId"
|
|
||||||
});
|
|
||||||
this.activity.runOnUiThread(new Runnable() {
|
this.activity.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user