'Get all available languages of the TTS
'Uses Reflection Lib, JavaObject Lib
Sub GetListOfAvailableLanguages() As ResumableSub
'Requires API 21 (Android 5.0) and above
'It is called like this:
'wait for (TTSFunctions.GetListOfAvailableLanguages) Complete (sLangs As String)
'manipulate the sLangs variable
Dim r As Reflector
Dim jo As JavaObject
jo.InitializeStatic(Application.PackageName & ".ttsfunctions")
jo.RunMethod("InitTTS", Array As Object(r.GetContext))
Sleep(4000)
Return jo.RunMethod("GetLanguages", Null)
End Sub
#IF JAVA
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import java.util.Locale;
import java.util.Set;
import java.util.Arrays;
import android.content.Context;
public static String sLangs;
public static TextToSpeech tts;
public static void InitTTS(Object objcon) {
Context context = (Context) objcon;
tts = new TextToSpeech(context, new OnInitListener(){
@Override
public void onInit(int status) {
};
});
};
public static String GetLanguages() {
Set<Locale> loc = tts.getAvailableLanguages();
Object[] objloc = loc.toArray();
sLangs = Arrays.toString(objloc);
return sLangs;
};
#End If