From 6cd4cbfea1c528b20873943053d963870cfe7280 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Aug 2024 21:22:14 +0300 Subject: [PATCH] Implement tts_voice setting and getting voice, volume and rate. --- NGTScript/tts_voice.cpp | 16 +++++++++++++--- SRAL | 2 +- ngt-docs | 2 +- tests/test.txt | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 tests/test.txt diff --git a/NGTScript/tts_voice.cpp b/NGTScript/tts_voice.cpp index 171e659..32fd0bc 100644 --- a/NGTScript/tts_voice.cpp +++ b/NGTScript/tts_voice.cpp @@ -42,7 +42,14 @@ bool TTSVoice::speak_interrupt_wait(const std::string& text) std::vector TTSVoice::get_voice_names() { - return {}; + std::vector names; + uint64_t count = SRAL_GetVoiceCountEx(ENGINE_SAPI); + if (count == 0)return{}; + for (uint64_t i = 0; i < count; ++i) { + const char* name = SRAL_GetVoiceNameEx(ENGINE_SAPI, i); + names.push_back(std::string(name)); + } + return names; } CScriptArray* TTSVoice::get_voice_names_script() { asIScriptContext* ctx = asGetActiveContext(); @@ -61,22 +68,25 @@ CScriptArray* TTSVoice::get_voice_names_script() { } void TTSVoice::set_voice(uint64_t voice_index) { + SRAL_SetVoiceEx(ENGINE_SAPI, voice_index); } int TTSVoice::get_rate() const { - return 0; + return SRAL_GetRateEx(ENGINE_SAPI); } void TTSVoice::set_rate(int new_rate) { + SRAL_SetRateEx(ENGINE_SAPI, new_rate); } int TTSVoice::get_volume() const { - return 0; + return SRAL_GetVolumeEx(ENGINE_SAPI);; } void TTSVoice::set_volume(int new_volume) { + SRAL_SetVolumeEx(ENGINE_SAPI, new_volume); } diff --git a/SRAL b/SRAL index f90c53d..a93f15c 160000 --- a/SRAL +++ b/SRAL @@ -1 +1 @@ -Subproject commit f90c53d32b7b1b0a8f0fe925488593098f8aa5ed +Subproject commit a93f15ccc7aad1a74b73b12d3b7d004d5aa0482a diff --git a/ngt-docs b/ngt-docs index 11e175e..162a06d 160000 --- a/ngt-docs +++ b/ngt-docs @@ -1 +1 @@ -Subproject commit 11e175e82e6e4db7f9c1ebb5452ef2d63334ea2e +Subproject commit 162a06d8077f03689c8bff6c06ee7d4364803c27 diff --git a/tests/test.txt b/tests/test.txt new file mode 100644 index 0000000..99d14c7 --- /dev/null +++ b/tests/test.txt @@ -0,0 +1 @@ +Автоматическое переключение диалектов - если поддерживается, флажок не отмечено. \ No newline at end of file