Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 1cb8e48

Browse files
committed
[[ UnicodeSpeech ]] Updated revSpeech to work with Unicode.
1 parent 9d7f40b commit 1cb8e48

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

revspeech/revspeech.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
/* End PBXContainerItemProxy section */
3232

3333
/* Begin PBXFileReference section */
34+
4D7113541991129F00C1710F /* w32sapi4speech.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = w32sapi4speech.cpp; path = src/w32sapi4speech.cpp; sourceTree = "<group>"; };
35+
4D7113551991129F00C1710F /* w32sapi4speech.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = w32sapi4speech.h; path = src/w32sapi4speech.h; sourceTree = "<group>"; };
36+
4D7113561991129F00C1710F /* w32sapi5speech.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = w32sapi5speech.cpp; path = src/w32sapi5speech.cpp; sourceTree = "<group>"; };
37+
4D7113571991129F00C1710F /* w32sapi5speech.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = w32sapi5speech.h; path = src/w32sapi5speech.h; sourceTree = "<group>"; };
38+
4D7113581991129F00C1710F /* w32speech.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = w32speech.cpp; path = src/w32speech.cpp; sourceTree = "<group>"; };
3439
E82D44A11713199700A10289 /* revspeech.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = revspeech.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
3540
E82D44B217131A4800A10289 /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = ../rules/Debug.xcconfig; sourceTree = "<group>"; };
3641
E82D44B317131A4800A10289 /* Global.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Global.xcconfig; path = ../rules/Global.xcconfig; sourceTree = "<group>"; };
@@ -106,6 +111,11 @@
106111
E82D44B917131B3500A10289 /* Source */ = {
107112
isa = PBXGroup;
108113
children = (
114+
4D7113541991129F00C1710F /* w32sapi4speech.cpp */,
115+
4D7113551991129F00C1710F /* w32sapi4speech.h */,
116+
4D7113561991129F00C1710F /* w32sapi5speech.cpp */,
117+
4D7113571991129F00C1710F /* w32sapi5speech.h */,
118+
4D7113581991129F00C1710F /* w32speech.cpp */,
109119
E82D44BA17131B4700A10289 /* osxspeech.cpp */,
110120
E82D44BB17131B4700A10289 /* osxspeech.h */,
111121
E82D44BC17131B4700A10289 /* revspeech.cpp */,

revspeech/src/osxspeech.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool OSXSpeechNarrator::Finalize(void)
6464
return false;
6565
}
6666

67-
bool OSXSpeechNarrator::Start(const char* p_string)
67+
bool OSXSpeechNarrator::Start(const char* p_string, bool p_is_utf8)
6868
{
6969
if (SpeechStart(true) == false)
7070
{
@@ -73,7 +73,7 @@ bool OSXSpeechNarrator::Start(const char* p_string)
7373

7474
if (speechtext != nil)
7575
CFRelease(speechtext);
76-
speechtext = CFStringCreateWithCString(kCFAllocatorDefault, p_string, kCFStringEncodingMacRoman);
76+
speechtext = CFStringCreateWithCString(kCFAllocatorDefault, p_string, p_is_utf8 ? kCFStringEncodingUTF8 : kCFStringEncodingMacRoman);
7777
SpeakCFString(spchannel, speechtext, nil);
7878
return true;
7979
}

revspeech/src/osxspeech.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class OSXSpeechNarrator: public INarrator
3232
bool Initialize(void);
3333
bool Finalize(void);
3434

35-
bool Start(const char* p_string);
35+
bool Start(const char* p_string, bool p_is_utf8);
3636
bool Stop(void);
3737
bool Busy(void);
3838

revspeech/src/revspeech.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,34 @@ void revSpeechSpeak(char *args[], int nargs, char **retstring,
225225
{
226226
NarratorLoad();
227227

228-
s_narrator -> Start(args[0]);
228+
s_narrator -> Start(args[0], false);
229229
}
230230
else
231231
*error = True;
232232

233233
*retstring = result != NULL ? result : strdup("");
234234
}
235235

236+
void revSpeechSpeakUTF8(char *args[], int nargs, char **retstring,
237+
Bool *pass, Bool *error)
238+
{
239+
char *result = NULL;
240+
241+
*pass = False;
242+
*error = False;
243+
244+
if (nargs == 1)
245+
{
246+
NarratorLoad();
247+
248+
s_narrator -> Start(args[0], true);
249+
}
250+
else
251+
*error = True;
252+
253+
*retstring = result != NULL ? result : strdup("");
254+
}
255+
236256
void revSpeechStop(char *args[], int nargs, char **retstring,
237257
Bool *pass, Bool *error)
238258
{ char *result = NULL;
@@ -465,7 +485,8 @@ EXTERNAL_BEGIN_DECLARATIONS("revSpeech")
465485
EXTERNAL_DECLARE_COMMAND("revSetSpeechPitch", revSpeechPitch)
466486
EXTERNAL_DECLARE_COMMAND("revSetSpeechVolume", revSpeechSetVolume)
467487
EXTERNAL_DECLARE_FUNCTION("revGetSpeechVolume", revSpeechGetVolume)
468-
EXTERNAL_DECLARE_COMMAND("revSpeak", revSpeechSpeak)
488+
EXTERNAL_DECLARE_COMMAND("revSpeak", revSpeechSpeak)
489+
EXTERNAL_DECLARE_COMMAND_UTF8("revSpeak", revSpeechSpeakUTF8)
469490
EXTERNAL_DECLARE_COMMAND("revStopSpeech", revSpeechStop)
470491
EXTERNAL_DECLARE_FUNCTION("revIsSpeaking", revSpeechBusy)
471492
EXTERNAL_DECLARE_FUNCTION("revSpeechVoices", revSpeechVoices)

revspeech/src/revspeech.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class INarrator
4343
virtual bool Initialize(void) = 0;
4444
virtual bool Finalize(void) = 0;
4545

46-
virtual bool Start(const char* p_string) = 0;
46+
virtual bool Start(const char* p_string, bool p_is_utf8) = 0;
4747

4848
#ifdef FEATURE_REVSPEAKTOFILE
4949
virtual bool SpeakToFile(const char* p_string, const char* p_file) = 0;

0 commit comments

Comments
 (0)