mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-02 17:03:13 +00:00
GUI: U32: Use u32 for tts (MacOS)
This commit is contained in:
parent
bcbe2fe2ea
commit
0118839c59
@ -29,13 +29,14 @@
|
||||
|
||||
#include "common/text-to-speech.h"
|
||||
#include "common/queue.h"
|
||||
#include "common/ustr.h"
|
||||
|
||||
class MacOSXTextToSpeechManager : public Common::TextToSpeechManager {
|
||||
public:
|
||||
MacOSXTextToSpeechManager();
|
||||
virtual ~MacOSXTextToSpeechManager() override;
|
||||
|
||||
virtual bool say(Common::String str, Action action, Common::String charset = "") override;
|
||||
virtual bool say(const Common::U32String &str, Action action, Common::String charset = "") override;
|
||||
|
||||
virtual bool stop() override;
|
||||
virtual bool pause() override;
|
||||
@ -67,7 +68,7 @@ private:
|
||||
struct SpeechText {
|
||||
Common::String text;
|
||||
Common::String encoding;
|
||||
SpeechText(const Common::String& txt, const Common::String& enc) : text(txt), encoding(enc) {}
|
||||
SpeechText(const Common::String &txt, const Common::String &enc) : text(txt), encoding(enc) {}
|
||||
};
|
||||
Common::Queue<SpeechText> _messageQueue;
|
||||
Common::String _currentSpeech;
|
||||
|
@ -81,7 +81,8 @@ MacOSXTextToSpeechManager::~MacOSXTextToSpeechManager() {
|
||||
[synthesizerDelegate release];
|
||||
}
|
||||
|
||||
bool MacOSXTextToSpeechManager::say(Common::String text, Action action, Common::String encoding) {
|
||||
bool MacOSXTextToSpeechManager::say(const Common::U32String &text, Action action, Common::String encoding) {
|
||||
Common::String strToSpeak = text.encode();
|
||||
if (isSpeaking()) {
|
||||
// Interruptions are done on word boundaries for nice transitions.
|
||||
// Should we interrupt immediately?
|
||||
@ -94,14 +95,14 @@ bool MacOSXTextToSpeechManager::say(Common::String text, Action action, Common::
|
||||
// If the new speech is the one being currently said, continue that speech but clear the queue.
|
||||
// And otherwise both clear the queue and interrupt the current speech.
|
||||
_messageQueue.clear();
|
||||
if (_currentSpeech == text)
|
||||
if (_currentSpeech == strToSpeak)
|
||||
return true;
|
||||
[synthesizer stopSpeakingAtBoundary:NSSpeechWordBoundary];
|
||||
} else if (action == QUEUE_NO_REPEAT) {
|
||||
if (!_messageQueue.empty()) {
|
||||
if (_messageQueue.back().text == text)
|
||||
if (_messageQueue.back().text == strToSpeak)
|
||||
return true;
|
||||
} else if (_currentSpeech == text)
|
||||
} else if (_currentSpeech == strToSpeak)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -112,7 +113,7 @@ bool MacOSXTextToSpeechManager::say(Common::String text, Action action, Common::
|
||||
#endif
|
||||
}
|
||||
|
||||
_messageQueue.push(SpeechText(text, encoding));
|
||||
_messageQueue.push(SpeechText(strToSpeak, encoding));
|
||||
if (!isSpeaking())
|
||||
startNextSpeech();
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user