[orca] Fix KeyError resulting from existing "string" argument



commit 7eae2e08a7b943d32b776aa2a070a040b31ce262
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Apr 20 12:13:13 2022 +0200

    Fix KeyError resulting from existing "string" argument
    
    _generateCurrentLineText may be called with an existing "string"
    argument. Because we're potentially breaking the string up, based
    on attributes such as language or formatting, this existing argument
    is irrelevant. Plus calling voice() with two string arguments causes
    a KeyError which interrupts the generation. Handle this condition by
    removing the existing "string" argument before calling voice().

 src/orca/speech_generator.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/src/orca/speech_generator.py b/src/orca/speech_generator.py
index 08d6e320e..d71ea03c8 100644
--- a/src/orca/speech_generator.py
+++ b/src/orca/speech_generator.py
@@ -1243,6 +1243,11 @@ class SpeechGenerator(generator.Generator):
             if not string:
                 continue
             args["language"], args["dialect"] = language, dialect
+            if "string" in args:
+                msg = "INFO: Found existing string '%s'; using '%s'" % (args.get("string"), string)
+                debug.println(debug.LEVEL_INFO, msg)
+                args.pop("string")
+
             voice = self.voice(string=string, obj=obj, **args)
             string = self._script.utilities.adjustForLinks(obj, string, start)
             rv = [self._script.utilities.adjustForRepeats(string)]


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]