Skip to content

Commit

Permalink
Implement tts_voice setting and getting voice, volume and rate.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1maker committed Aug 20, 2024
1 parent 50218a1 commit 6cd4cbf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
16 changes: 13 additions & 3 deletions NGTScript/tts_voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ bool TTSVoice::speak_interrupt_wait(const std::string& text)

std::vector<std::string> TTSVoice::get_voice_names()
{
return {};
std::vector<std::string> 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();
Expand All @@ -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);
}
2 changes: 1 addition & 1 deletion SRAL
1 change: 1 addition & 0 deletions tests/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�������������� ������������ ��������� - ���� ��������������, ������ �� ��������.

0 comments on commit 6cd4cbf

Please sign in to comment.