/**************************************************************************/1/* tts_windows.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/string/ustring.h"33#include "core/templates/hash_map.h"34#include "core/templates/list.h"35#include "core/variant/array.h"36#include "servers/display_server.h"3738#include <objbase.h>39#include <sapi.h>40#include <winnls.h>41#include <cwchar>4243#define WIN32_LEAN_AND_MEAN44#include <windows.h>4546class TTS_Windows {47List<DisplayServer::TTSUtterance> queue;48ISpVoice *synth = nullptr;49bool paused = false;50struct UTData {51Char16String string;52int offset;53int id;54};55HashMap<uint32_t, UTData> ids;56bool update_requested = false;5758static void __stdcall speech_event_callback(WPARAM wParam, LPARAM lParam);5960static TTS_Windows *singleton;6162public:63static TTS_Windows *get_singleton();6465bool is_speaking() const;66bool is_paused() const;67Array get_voices() const;6869void speak(const String &p_text, const String &p_voice, int p_volume = 50, float p_pitch = 1.f, float p_rate = 1.f, int p_utterance_id = 0, bool p_interrupt = false);70void pause();71void resume();72void stop();7374void process_events();7576TTS_Windows();77~TTS_Windows();78};798081