[Scummvm-git-logs] scummvm master -> 025dd965f5f7d79105e14c525b0ca7b92ac73aae

criezy criezy at scummvm.org
Sun Jun 21 18:13:55 UTC 2020


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

Summary:
6c2aaba04f TESTBED: Add test for stopping speech and immediately starting another
025dd965f5 MACOSX: Fix TTS when stopping speech and immediately starting another


Commit: 6c2aaba04f0841afb120452359269b71452d58b7
    https://github.com/scummvm/scummvm/commit/6c2aaba04f0841afb120452359269b71452d58b7
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-06-21T19:09:49+01:00

Commit Message:
TESTBED: Add test for stopping speech and immediately starting another

Changed paths:
    engines/testbed/speech.cpp
    engines/testbed/speech.h


diff --git a/engines/testbed/speech.cpp b/engines/testbed/speech.cpp
index a0892dfcbb..754f7cc263 100644
--- a/engines/testbed/speech.cpp
+++ b/engines/testbed/speech.cpp
@@ -146,6 +146,43 @@ TestExitStatus Speechtests::testStop() {
 	return kTestPassed;
 }
 
+TestExitStatus Speechtests::testStopAndSpeak() {
+	Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
+	ttsMan->setLanguage("en");
+	ttsMan->setVolume(100);
+	ttsMan->setRate(0);
+	ttsMan->setPitch(0);
+	ttsMan->setVoice(ttsMan->getDefaultVoice());
+	Testsuite::clearScreen();
+	Common::String info = "Text to speech stop and speak test. You should expect a voice to start speaking and after approximately a second it should stop the speech and start another sentence.";
+
+	Common::Point pt(0, 100);
+	Testsuite::writeOnScreen("Testing TTS stop and speak", pt);
+
+	if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+		Testsuite::logPrintf("Info! Skipping test : testStop\n");
+		return kTestSkipped;
+	}
+
+	ttsMan->say("Testing text to speech, the speech should stop after approximately a second after it started, so it shouldn't have the time to read this.");
+	g_system->delayMillis(1000);
+	ttsMan->stop();
+	ttsMan->say("Now starting the second sentence.", Common::TextToSpeechManager::QUEUE);
+	ttsMan->say("You should hear that one in totality.", Common::TextToSpeechManager::QUEUE);
+	if (!ttsMan->isSpeaking()) {
+		Testsuite::logDetailedPrintf("Male TTS failed\n");
+		return kTestFailed;
+	}
+	waitForSpeechEnd(ttsMan);
+
+	Common::String prompt = "Did you hear a voice saying: \"Testing text to speech, the speech should stop after approximately a second after it started, so it shouldn't have the time to read this.\" but stopping in the middle, and then saying \"Now starting the second sentence. You should hear that one in totality.\"?";
+	if (!Testsuite::handleInteractiveInput(prompt, "Yes", "No", kOptionLeft)) {
+		Testsuite::logDetailedPrintf("TTS stop failed\n");
+		return kTestFailed;
+	}
+	return kTestPassed;
+}
+
 TestExitStatus Speechtests::testPauseResume() {
 	Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
 	ttsMan->setLanguage("en");
@@ -509,6 +546,7 @@ SpeechTestSuite::SpeechTestSuite() {
 	addTest("testMale", &Speechtests::testMale, true);
 	addTest("testFemale", &Speechtests::testFemale, true);
 	addTest("testStop", &Speechtests::testStop, true);
+	addTest("testStopAndSpeak", &Speechtests::testStopAndSpeak, true);
 	addTest("testPauseResume", &Speechtests::testPauseResume, true);
 	addTest("testRate", &Speechtests::testRate, true);
 	addTest("testVolume", &Speechtests::testVolume, true);
diff --git a/engines/testbed/speech.h b/engines/testbed/speech.h
index 37cdd9aff8..425c6c7f6d 100644
--- a/engines/testbed/speech.h
+++ b/engines/testbed/speech.h
@@ -38,6 +38,7 @@ namespace Speechtests {
 TestExitStatus testMale();
 TestExitStatus testFemale();
 TestExitStatus testStop();
+TestExitStatus testStopAndSpeak();
 TestExitStatus testPauseResume();
 TestExitStatus testRate();
 TestExitStatus testVolume();


Commit: 025dd965f5f7d79105e14c525b0ca7b92ac73aae
    https://github.com/scummvm/scummvm/commit/025dd965f5f7d79105e14c525b0ca7b92ac73aae
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-06-21T19:13:02+01:00

Commit Message:
MACOSX: Fix TTS when stopping speech and immediately starting another

Changed paths:
    backends/text-to-speech/macosx/macosx-text-to-speech.mm


diff --git a/backends/text-to-speech/macosx/macosx-text-to-speech.mm b/backends/text-to-speech/macosx/macosx-text-to-speech.mm
index 66feb54d4b..3f19653408 100644
--- a/backends/text-to-speech/macosx/macosx-text-to-speech.mm
+++ b/backends/text-to-speech/macosx/macosx-text-to-speech.mm
@@ -33,20 +33,29 @@
 
 @interface MacOSXTextToSpeechManagerDelegate : NSObject<NSSpeechSynthesizerDelegate> {
 	MacOSXTextToSpeechManager *_ttsManager;
+	BOOL _ignoreNextFinishedSpeaking;
 }
 - (id)initWithManager:(MacOSXTextToSpeechManager*)ttsManager;
 - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking;
+- (void)ignoreNextFinishedSpeaking:(BOOL)ignore;
 @end
 
 @implementation MacOSXTextToSpeechManagerDelegate
 - (id)initWithManager:(MacOSXTextToSpeechManager*)ttsManager {
 	self = [super init];
 	_ttsManager = ttsManager;
+	_ignoreNextFinishedSpeaking = NO;
 	return self;
 }
 
 - (void)speechSynthesizer:(NSSpeechSynthesizer *)sender didFinishSpeaking:(BOOL)finishedSpeaking {
-	_ttsManager->startNextSpeech();
+	if (!_ignoreNextFinishedSpeaking)
+		_ttsManager->startNextSpeech();
+	_ignoreNextFinishedSpeaking = NO;
+}
+
+- (void)ignoreNextFinishedSpeaking:(BOOL)ignore {
+	_ignoreNextFinishedSpeaking = ignore;
 }
 @end
 
@@ -133,9 +142,15 @@ bool MacOSXTextToSpeechManager::startNextSpeech() {
 
 bool MacOSXTextToSpeechManager::stop() {
 	_messageQueue.clear();
-	_currentSpeech.clear(); // so that it immediately reports that it is no longer speeking
-	// Stop as soon as possible
-	[synthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary];
+	if (isSpeaking()) {
+		_currentSpeech.clear(); // so that it immediately reports that it is no longer speeking
+		// Stop as soon as possible
+		// Also tell the MacOSXTextToSpeechManagerDelegate to ignore the next finishedSpeaking as
+		// it has already been handled, but we might have started another speach by the time we
+		// receive it, and we don't want to stop that one.
+		[synthesizerDelegate ignoreNextFinishedSpeaking:YES];
+		[synthesizer stopSpeakingAtBoundary:NSSpeechImmediateBoundary];
+	}
 	return true;
 }
 




More information about the Scummvm-git-logs mailing list