[Scummvm-git-logs] scummvm master -> ea9a7dccf14646aa3b016109b6da4fe921ff8161

criezy criezy at scummvm.org
Sat Sep 4 18:27:48 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
ea9a7dccf1 DREAMWEB: Add Text To Speech support


Commit: ea9a7dccf14646aa3b016109b6da4fe921ff8161
    https://github.com/scummvm/scummvm/commit/ea9a7dccf14646aa3b016109b6da4fe921ff8161
Author: taylorzhancher (77198777+taylorzhancher at users.noreply.github.com)
Date: 2021-09-04T19:27:46+01:00

Commit Message:
DREAMWEB: Add Text To Speech support

Changed paths:
    engines/dreamweb/detection.cpp
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/newplace.cpp
    engines/dreamweb/sound.cpp
    engines/dreamweb/stubs.cpp
    engines/dreamweb/talk.cpp
    engines/dreamweb/titles.cpp
    engines/dreamweb/use.cpp


diff --git a/engines/dreamweb/detection.cpp b/engines/dreamweb/detection.cpp
index a208f3fa47..44446169b6 100644
--- a/engines/dreamweb/detection.cpp
+++ b/engines/dreamweb/detection.cpp
@@ -25,12 +25,16 @@
 #include "common/algorithm.h"
 #include "common/system.h"
 #include "common/translation.h"
+#include "common/text-to-speech.h"
 
 #include "engines/advancedDetector.h"
 
 #include "dreamweb/detection.h"
 #include "dreamweb/dreamweb.h"
 
+#define GAMEOPTION_TTS_THINGS 	GUIO_GAMEOPTIONS1
+#define GAMEOPTION_TTS_SPEECH 	GUIO_GAMEOPTIONS2
+
 static const PlainGameDescriptor dreamWebGames[] = {
 	{ "dreamweb", "DreamWeb" },
 	{ 0, 0 }
@@ -65,6 +69,28 @@ static const ADExtraGuiOptionsMap gameGuiOptions[] = {
 		}
 	},
 
+#ifdef USE_TTS
+	{
+		GAMEOPTION_TTS_THINGS,
+		{
+			_s("Enable Text to Speech for Objects, Options, and the Bible Quote"),
+			_s("Use TTS to read the descriptions (if TTS is available)"),
+			"tts_enabled_objects",
+			false
+		}
+	},
+
+	{
+		GAMEOPTION_TTS_SPEECH,
+		{
+			_s("Enable Text to Speech for Subtitles"),
+			_s("Use TTS to read the subtitles (if TTS is available)"),
+			"tts_enabled_speech",
+			false
+		}
+	},
+#endif
+
 	AD_EXTRA_GUI_OPTIONS_TERMINATOR
 };
 
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 95b6e04603..5ceb4c42af 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -37,6 +37,8 @@
 #include "dreamweb/sound.h"
 #include "dreamweb/dreamweb.h"
 
+#include "common/text-to-speech.h"
+
 namespace DreamWeb {
 
 DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gameDesc) :
@@ -52,6 +54,8 @@ DreamWebEngine::DreamWebEngine(OSystem *syst, const DreamWebGameDescription *gam
 	_turbo = false;
 	_oldMouseState = 0;
 
+	_ttsMan = g_system->getTextToSpeechManager();
+
 	_datafilePrefix = "DREAMWEB.";
 	_speechDirName = "SPEECH";
 	// ES and FR CD release use a different data file prefix
@@ -391,6 +395,22 @@ void DreamWebEngine::processEvents(bool processSoundEvents) {
 }
 
 Common::Error DreamWebEngine::run() {
+	if (_ttsMan != nullptr) {
+		Common::String languageString = Common::getLanguageCode(getLanguage());
+		_ttsMan->setLanguage(languageString);
+		switch (getLanguage()) {
+		case Common::RU_RUS:
+			_textEncoding = Common::kDos866;
+			break;
+		case Common::CZ_CZE:
+			_textEncoding = Common::kWindows1250;
+			break;
+		default:
+			_textEncoding = Common::kDos850;
+			break;
+		}
+	}
+
 	syncSoundSettings();
 	setDebugger(new DreamWebConsole(this));
 	_sound = new DreamWebSound(this);
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 3e65e2c115..8374ea2939 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -430,6 +430,10 @@ public:
 	uint8 _lineDirection;
 	uint8 _lineLength;
 
+	Common::String _lastText;
+	Common::TextToSpeechManager *_ttsMan;
+	Common::CodePage _textEncoding;
+
 	// from backdrop.cpp
 	void doBlocks();
 	uint8 getXAd(const uint8 *setData, uint8 *result);
@@ -876,6 +880,7 @@ public:
 	void lookAtCard();
 	void obsThatDoThings();
 	void describeOb();
+	void speakObject(const char *text);
 	void putBackObStuff();
 	void showDiaryPage();
 	void showDiaryKeys();
diff --git a/engines/dreamweb/newplace.cpp b/engines/dreamweb/newplace.cpp
index 3834a114e5..75ee2ed534 100644
--- a/engines/dreamweb/newplace.cpp
+++ b/engines/dreamweb/newplace.cpp
@@ -23,6 +23,9 @@
 #include "dreamweb/sound.h"
 #include "dreamweb/dreamweb.h"
 
+#include "common/text-to-speech.h"
+#include "common/config-manager.h"
+
 namespace DreamWeb {
 
 void DreamWebEngine::newPlace() {
@@ -121,6 +124,10 @@ void DreamWebEngine::lookAtPlace() {
 
 	const uint8 *string = (const uint8 *)_travelText.getString(_destPos);
 	findNextColon(&string);
+
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects"))
+		_ttsMan->say((const char *)string, _textEncoding);
+
 	uint16 y = (_foreignRelease) ? 84 + 4 : 84;
 	printDirect(&string, 63, &y, 191, 191 & 1);
 	workToScreenM();
@@ -153,6 +160,8 @@ void DreamWebEngine::locationPic() {
 
 	const uint8 *string = (const uint8 *)_travelText.getString(_destPos);
 	printDirect(string, 50, 20, 241, 241 & 1);
+
+	speakObject((const char *)string);
 }
 
 void DreamWebEngine::showArrows() {
diff --git a/engines/dreamweb/sound.cpp b/engines/dreamweb/sound.cpp
index 2a4cd9c75c..43fab6acd0 100644
--- a/engines/dreamweb/sound.cpp
+++ b/engines/dreamweb/sound.cpp
@@ -186,7 +186,7 @@ void DreamWebSound::stopSound(uint8 channel) {
 }
 
 bool DreamWebSound::loadSpeech(const Common::String &filename) {
-	if (!_vm->hasSpeech())
+	if (ConfMan.getBool("tts_enabled_speech") || !_vm->hasSpeech())
 		return false;
 
 	Common::File file;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index ef18b93097..16af26f0b8 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -25,6 +25,7 @@
 #include "engines/util.h"
 #include "common/config-manager.h"
 #include "common/file.h"
+#include "common/text-to-speech.h"
 
 namespace DreamWeb {
 
@@ -963,6 +964,14 @@ void DreamWebEngine::useTimedText() {
 
 	const uint8 *string = (const uint8 *)_timedTemp._string;
 	printDirect(string, _timedTemp._x, _timedTemp._y, 237, true);
+	const char *theText = (const char *)string;
+	if (_lastText != theText) {
+		if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_speech")) {
+			_ttsMan->say(theText, _textEncoding);
+		}
+		_lastText = theText;
+	}
+
 	_needToDumpTimed = 1;
 }
 
@@ -1174,7 +1183,12 @@ void DreamWebEngine::commandOnlyCond(uint8 command, uint8 commandType) {
 void DreamWebEngine::commandOnly(uint8 command) {
 	delTextLine();
 	const uint8 *string = (const uint8 *)_commandText.getString(command);
+
 	printDirect(string, _textAddressX, _textAddressY, _textLen, (bool)(_textLen & 1));
+
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects") && *string != 0)
+		_ttsMan->say((const char *)string, _textEncoding);
+
 	_newTextLine = 1;
 }
 
@@ -1261,6 +1275,8 @@ void DreamWebEngine::copyName(uint8 type, uint8 index, uint8 *dst) {
 }
 
 void DreamWebEngine::commandWithOb(uint8 command, uint8 type, uint8 index) {
+	Common::String theText;
+
 	uint8 commandLine[64] = "OBJECT NAME ONE                         ";
 	delTextLine();
 	uint8 textLen = _textLen;
@@ -1273,6 +1289,9 @@ void DreamWebEngine::commandWithOb(uint8 command, uint8 type, uint8 index) {
 
 	if (getLanguage() != Common::RU_RUS) {
 		printDirect(string, _textAddressX, _textAddressY, textLen, (bool)(textLen & 1));
+		if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects")) {
+			theText += (const char *)string;
+		}
 
 		copyName(type, index, commandLine);
 
@@ -1280,6 +1299,11 @@ void DreamWebEngine::commandWithOb(uint8 command, uint8 type, uint8 index) {
 		if (command != 0)
 			x += 5;
 		printDirect(commandLine, x, _textAddressY, textLen, (bool)(textLen & 1));
+		if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects")) {
+			theText += (const char *)commandLine;
+			_ttsMan->say(theText, _textEncoding);
+		}
+
 	} else {
 		copyName(type, index, commandLine);
 		printDirect(commandLine, _textAddressX, _textAddressY, textLen, (bool)(textLen & 1));
@@ -1941,6 +1965,13 @@ void DreamWebEngine::doLook() {
 	dumpTextLine();
 	uint8 index = _roomNum & 31;
 	const uint8 *string = (const uint8 *)_roomDesc.getString(index);
+
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects")) {
+		const char *placeName = (const char *)string;
+		const char *desRoom = strchr(placeName, ':') + 1;
+		_ttsMan->say(desRoom, _textEncoding);
+	}
+
 	findNextColon(&string);
 	uint16 x;
 	if (_realLocation < 50)
@@ -2337,6 +2368,14 @@ void DreamWebEngine::obsThatDoThings() {
 	}
 }
 
+void DreamWebEngine::speakObject(const char *text) {
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects")) {
+		const char *colon_pos = strchr(text, ':');
+		Common::String result(text, colon_pos ? colon_pos - text : strlen(text));
+		_ttsMan->say(result, _textEncoding);
+	}
+}
+
 void DreamWebEngine::describeOb() {
 	const uint8 *obText = getObTextStart();
 	uint16 y = 92;
@@ -2348,6 +2387,7 @@ void DreamWebEngine::describeOb() {
 		useCharsetIcons1();
 
 	printDirect(&obText, 33, &y, 241, 241 & 1);
+	speakObject((const char *)obText);
 
 	if (getLanguage() == Common::RU_RUS)
 		resetCharset();
diff --git a/engines/dreamweb/talk.cpp b/engines/dreamweb/talk.cpp
index 0ab25f742d..855336d6db 100644
--- a/engines/dreamweb/talk.cpp
+++ b/engines/dreamweb/talk.cpp
@@ -22,6 +22,8 @@
 
 #include "dreamweb/sound.h"
 #include "dreamweb/dreamweb.h"
+#include "common/text-to-speech.h"
+#include "common/config-manager.h"
 
 namespace DreamWeb {
 
@@ -92,6 +94,12 @@ void DreamWebEngine::startTalk() {
 
 	_charShift = 91+91;
 
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_speech")) {
+		const char *text = (const char *)str;
+		const char *goodText = strchr(text, ':') + 1;
+		_ttsMan->say(goodText, _textEncoding);
+	}
+
 	if (getLanguage() == Common::RU_RUS)
 		useCharsetIcons1();
 
@@ -115,7 +123,10 @@ void DreamWebEngine::startTalk() {
 }
 
 const uint8 *DreamWebEngine::getPersonText(uint8 index, uint8 talkPos) {
-	return (const uint8 *)_personText.getString(index*64 + talkPos);
+	const uint8 *text = (const uint8 *)_personText.getString(index*64 + talkPos);
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_speech"))
+		_ttsMan->say((const char *)text, Common::TextToSpeechManager::INTERRUPT, _textEncoding);
+	return text;
 }
 
 void DreamWebEngine::moreTalk() {
diff --git a/engines/dreamweb/titles.cpp b/engines/dreamweb/titles.cpp
index f0b77b9691..042858fcd8 100644
--- a/engines/dreamweb/titles.cpp
+++ b/engines/dreamweb/titles.cpp
@@ -23,6 +23,8 @@
 #include "dreamweb/sound.h"
 #include "dreamweb/dreamweb.h"
 #include "engines/util.h"
+#include "common/text-to-speech.h"
+#include "common/config-manager.h"
 
 namespace DreamWeb {
 
@@ -99,6 +101,54 @@ void DreamWebEngine::gettingShot() {
 }
 
 void DreamWebEngine::bibleQuote() {
+	const char *enStory = "And I heard a great voice out of the temple saying to the seven angels, "
+						"Go your ways and pour out the vails of the wrath of god upon the earth. "
+						"Book of revelation Chapter 16 verse 1.";
+	const char *frStory = "Puis j'entendis une voix forte qui venait du temple et disait aux sept anges: "
+						"Allez verser sur la terre les sept coupes de la col\xC3\xA8re de Dieu. "
+						"L'Apocalypse, chapitre 16, verset 1";
+	const char *esStory = "O\xC3\xAD una gran voz que dec\xC3\xAD""a"" desde el templo a los siete \xC3\xA1ngeles: "
+						"Id y derramad sobre la tierra las siete copas de la ira de Dios. "
+						"Apocalipsis, cap\xC3\xADtulo 16, vers\xC3\xAD""culo"" primero.";
+	const char *deStory = "Dann h\xC3\xB6rte ich, wie eine laute Stimme aus dem Tempel den sieben Engeln zurief: "
+						"Geht und gie\xC3\x9Ft die sieben Schalen mit dem Zorn Gottes \xC3\xBC""ber"" die Erde. "
+						"Offenbarung des Johannes. Kapitel 16 Vers 1";
+	const char *itStory = "Udii poi una gran voce dal tempio che diceva ai sette angeli: "
+						"Andate e versate sulla terra le sette coppe dell'ira di Dio. "
+						"Dal libro dell'Apocalisse, capitolo uno, primo versetto";
+	const char *ruStory = "\xD1\x83\xD1\x81\xD0\xBB\xD1\x8B\xD1\x88\xD0\xB0\xD0\xBB \xD1\x8F \xD0\xB8\xD0\xB7 \xD1\x85\xD1\x80\xD0\xB0\xD0\xBC\xD0\xB0 \xD1\x80\xD1\x8F\xD1\x89\xD0\xB8\xD0\xB9 \xD1\x81\xD0\xB5\xD0\xBC\xD0\xB8 \xD0\x90\xD0\xBD\xD0\xB3\xD0\xB5\xD0\xBB\xD0\xB0\xD0\xBC\x3A: "
+						"\xD0\xB8\xD0\xB4\xD0\xB8\xD1\x82\xD0\xB5 \xD0\xB8 \xD0\xB2\xD1\x8B\xD0\xBB\xD0\xB5\xD0\xB9\xD1\x82\xD0\xB5 \xD1\x81\xD0\xB5\xD0\xBC\xD1\x8C \xD1\x87\xD0\xB0\xD1\x88 \xD0\xB3\xD0\xBD\xD0\xB5\xD0\xB2\xD0\xB0 \xD0\x91\xD0\xBE\xD0\xB6\xD0\xB8\xD1\x8F \xD0\xBD\xD0\xB0 \xD0\xB7\xD0\xB5\xD0\xBC\xD0\xBB\xD1\x8E\x2E. "
+						"\xD0\x9E\xD0\xA2\xD0\x9A\xD0\xA0\xD0\x9E\xD0\x92\xD0\x95\xD0\x9D\xD0\x98\xD0\x95 \xD0\x98\xD0\x9E\xD0\x90\xD0\x9D\xD0\x9D\xD0\x90 \xD0\x91\xD0\x9E\xD0\x93\xD0\x9E\xD0\xA1\xD0\x9B\xD0\x9E\xD0\x92\xD0\x90 16:1";
+	const char *csStory = "Tu jsem usly\xC5\xA1""el"" mocn\xC3\xBD hlas ze svatyn\xC4\x9B, kter\xC3\xBD t\xC4\x9Bm sedmi and\xC4\x9Bl\xC5\xAFm \xC5\x99\xC3\xADkal: "
+						"Jd\xC4\x9Bte a vylejte t\xC4\x9B""ch"" sedm misek Bo\xC5\xBE\xC3\xADho hn\xC4\x9Bvu na zem. "
+						"Zjeven\xC3\xAD 16 ver\xC5\xA1 1";
+
+
+	const char *theStory;
+	switch(getLanguage()) {
+	case Common::ES_ESP:
+		theStory = esStory;
+		break;
+	case Common::FR_FRA:
+		theStory = frStory;
+		break;
+	case Common::IT_ITA:
+		theStory = itStory;
+		break;
+	case Common::DE_DEU:
+		theStory = deStory;
+		break;
+	case Common::RU_RUS:
+		theStory = ruStory;
+		break;
+	case Common::CZ_CZE:
+		theStory = csStory;
+		break;
+	default:
+		theStory = enStory;
+		break;
+	}
+
 	initGraphics(640, 480);
 
 	showPCX("I00");
@@ -110,7 +160,15 @@ void DreamWebEngine::bibleQuote() {
 		return; // "biblequotearly"
 	}
 
-	hangOne(560);
+	if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects")) {
+		_ttsMan->say(theStory);
+		while (_ttsMan->isSpeaking() && _lastHardKey != Common::KEYCODE_ESCAPE)
+			hangOne(1);
+		_ttsMan->stop();
+
+	} else
+		hangOne(560);
+
 	if (_lastHardKey == Common::KEYCODE_ESCAPE) {
 		_lastHardKey = Common::KEYCODE_INVALID;
 		return; // "biblequotearly"
diff --git a/engines/dreamweb/use.cpp b/engines/dreamweb/use.cpp
index c393fa1173..79c91f4483 100644
--- a/engines/dreamweb/use.cpp
+++ b/engines/dreamweb/use.cpp
@@ -23,6 +23,9 @@
 #include "dreamweb/sound.h"
 #include "dreamweb/dreamweb.h"
 
+#include "common/config-manager.h"
+#include "common/text-to-speech.h"
+
 namespace DreamWeb {
 
 
@@ -144,6 +147,9 @@ void DreamWebEngine::useRoutine() {
 	if (findNextColon(&obText) != 0) {
 		if (findNextColon(&obText) != 0) {
 			if (*obText != 0) {
+				if (_ttsMan != nullptr && ConfMan.getBool("tts_enabled_objects")) {
+					_ttsMan->say((const char *)obText, Common::TextToSpeechManager::INTERRUPT, _textEncoding);
+				}
 				useText(obText);
 				hangOnP(400);
 				putBackObStuff();
@@ -179,6 +185,9 @@ void DreamWebEngine::showFirstUse() {
 	findNextColon(&obText);
 	findNextColon(&obText);
 	useText(obText);
+
+	speakObject((const char *)obText);
+
 	hangOnP(400);
 }
 
@@ -188,6 +197,9 @@ void DreamWebEngine::showSecondUse() {
 	findNextColon(&obText);
 	findNextColon(&obText);
 	useText(obText);
+
+	speakObject((const char *)obText);
+
 	hangOnP(400);
 }
 




More information about the Scummvm-git-logs mailing list