Repository: fniessink/toisto (language: python)

Issue:
When repeating the spoken text, make it slower



Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 10d18b88..fb3527e6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 - Print the progress report dramatically (character by character) to make it stand out more.
 - Add support for the past perfect tense. Closes [#660](https://github.com/fniessink/toisto/issues/660).
 - Add word order quizzes for sentences with five or more words. Closes [#757](https://github.com/fniessink/toisto/issues/757).
+- When hitting enter at an empty prompt to have Toisto repeat the word or sentence, say it more slowly. Closes [#779](https://github.com/fniessink/toisto/issues/779).
 
 ## 0.22.0 - 2024-07-29
 
diff --git a/src/toisto/command/practice.py b/src/toisto/command/practice.py
index d4fd7dec..2ea6fb45 100644
--- a/src/toisto/command/practice.py
+++ b/src/toisto/command/practice.py
@@ -19,10 +19,12 @@
 
 def do_quiz_attempt(quiz: Quiz, config: ConfigParser, attempt: int) -> Label:
     """Present the question and get the answer from the user."""
+    repeat_speech = False
     while True:
-        say(quiz.question.language, quiz.question.pronounceable, config, slow=attempt > 1)
+        say(quiz.question.language, quiz.question.pronounceable, config, slow=repeat_speech or attempt > 1)
         if answer := Label(quiz.answer.language, input("> ").strip()):
             break
+        repeat_speech = True
         print("\033[F", end="")  # noqa: T201  # Move cursor one line up
     return answer
 


Test patch:
diff --git a/tests/toisto/command/test_practice.py b/tests/toisto/command/test_practice.py
index 0a221f90..13c0d84a 100644
--- a/tests/toisto/command/test_practice.py
+++ b/tests/toisto/command/test_practice.py
@@ -118,9 +118,11 @@ def test_answer_with_question_grammar_quiz(self):
 
     @patch("builtins.input", Mock(side_effect=["\n", "Hoi\n"]))
     @patch("builtins.print")
-    def test_quiz_empty_answer(self, mock_print: Mock) -> None:
-        """Test that the user is quizzed."""
+    @patch("toisto.command.practice.say")
+    def test_quiz_empty_answer(self, mock_say: Mock, mock_print: Mock) -> None:
+        """Test that the speech is repeated more slowly when the user hits enter without answer."""
         self.practice(self.quizzes)
+        self.assertEqual({"slow": True}, mock_say.call_args_list[-1][-1])
         self.assertEqual([call("\x1b[F", end="")], mock_print.call_args_list)
 
     @patch("builtins.input", Mock(return_value="hoi\n"))