/**************************************************************************/1/* tts_android.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/config/project_settings.h"33#include "core/string/ustring.h"34#include "core/templates/hash_map.h"35#include "core/variant/array.h"36#include "servers/display_server.h"3738#include <jni.h>3940class TTS_Android {41static inline int INIT_STATE_UNKNOWN = 0;42static inline int INIT_STATE_SUCCESS = 1;43static inline int INIT_STATE_FAIL = -1;4445static bool initialized;46static jobject tts;47static jclass cls;4849static jmethodID _init;50static jmethodID _is_speaking;51static jmethodID _is_paused;52static jmethodID _get_state;53static jmethodID _get_voices;54static jmethodID _speak;55static jmethodID _pause_speaking;56static jmethodID _resume_speaking;57static jmethodID _stop_speaking;5859static Thread init_thread;60static SafeFlag quit_request;61static SafeFlag init_done;6263static void _thread_function(void *self);6465static HashMap<int, Char16String> ids;6667static void initialize_tts(bool p_wait = true);6869public:70static void setup(jobject p_tts);71static void terminate();72static void _java_utterance_callback(int p_event, int p_id, int p_pos);7374static bool is_speaking();75static bool is_paused();76static Array get_voices();77static void speak(const String &p_text, const String &p_voice, int p_volume, float p_pitch, float p_rate, int p_utterance_id, bool p_interrupt);78static void pause();79static void resume();80static void stop();81};828384