Skip to content

Commit

Permalink
fix issue #16 No speech cyrillics
Browse files Browse the repository at this point in the history
- added converter from utf8 to utf16 needed by SAPI
  • Loading branch information
chcg committed Jul 10, 2024
1 parent 4ad11b2 commit 05e9e78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions SpeechPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <sapi.h>

#include <string>
#include <codecvt>
#include <cassert>

const TCHAR PLUGIN_NAME[] = __TEXT("Speech");
Expand Down Expand Up @@ -239,7 +240,9 @@ void SpeakDocument()

SendMessage(editHandle, SCI_GETTEXT, buf.size(), (LPARAM)&buf[0]);

std::wstring wbuf(buf.begin(), buf.end());
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::wstring wbuf = converter.from_bytes(buf);

SpeekText(wbuf);
}
}
Expand All @@ -265,7 +268,9 @@ void SpeakSelection()
tr.lpstrText = &buf[0];
SendMessage(editHandle, SCI_GETTEXTRANGE, 0, (LPARAM)&tr);

std::wstring wbuf(buf.begin(), buf.end());
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::wstring wbuf = converter.from_bytes(buf);

SpeekText(wbuf);
}
else
Expand Down
12 changes: 6 additions & 6 deletions SpeechPlugin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;C:\Program Files\Microsoft Speech SDK 5.1\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_DEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
Expand Down Expand Up @@ -141,7 +141,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;C:\Program Files\Microsoft Speech SDK 5.1\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_DEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
Expand Down Expand Up @@ -169,7 +169,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;C:\Program Files\Microsoft Speech SDK 5.1\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_DEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
Expand All @@ -196,7 +196,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>.;C:\Program Files\Microsoft Speech SDK 5.1\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;NDEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader />
<PrecompiledHeaderFile />
Expand Down Expand Up @@ -224,7 +224,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<AdditionalIncludeDirectories>.;C:\Program Files\Microsoft Speech SDK 5.1\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;NDEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
Expand Down Expand Up @@ -253,7 +253,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<AdditionalIncludeDirectories>.;C:\Program Files\Microsoft Speech SDK 5.1\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;NDEBUG;_WINDOWS;_USRDLL;NPPSPEECHPLUGIN_EXPORTS;_WIN32_DCOM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
Expand Down

0 comments on commit 05e9e78

Please sign in to comment.