This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
AI Audio Speech Complexity, Undefined Variables, and TTS Error Handling #3166
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The function named
handle_speak
was initially analyzed to be having a Cognitive Complexity of 24, which is high and it makes the function hard to comprehend, detect errors in, and modify. This complexity was mainly because this function has a large number of lines of code, and has many control flow indention levels. With this in mind, the function was partitioned and divided into sub-functions dubbed ‘Helper’ functions with each having a particular mandate to fulfill. This kind of refactoring is valuable for simplification of code so that experiences developers could understand it easily. Also, the TTS errors were fine-tuned in order to have better approach towards managing the errors and to protect the system by allowing a shift to the Mimic TTS service incase the service degrades.Undefined Variable
The script uses an undefined variable termed as ‘utterance’ which, if invoked in the body of a script without declaration may result into a run time error. This change reduces possible crashes or a halt of a script where uninitialized variables are used by making code more stable and less buggy.
How to Test
Functionality Testing: Check the function
handle_speak
to the new functional scenario and make sure that the function succeeds in its work without the relatively high cognitive complexity which was identified before. Make sure that positively refactored sub-functions work properly and that overall logic of the function is correct.Undefined Variable Testing: Check that the
utterance
variable is well set and proceeds through all the functions involved in the process. Make sure that you do not get runtime errors arising from failure to initialize some of the variables.TTS Error Handling Testing: Execute the Text-to-Speech feature and fake an issue with the initial TTS service and check whether the system transitions to the Mimic TTS service without interruption in speech production. Make sure that the correct error messages are produced during the process.
Contributor license agreement signed?
CLA [ ] (Whether you have signed a CLA - Contributor Licensing Agreement