Well, both are grammatical but extremely awkward. There's no reason to have both "speak" and "utter" in the same sentence, as they're synonyms. Why not just say "The words were uttered" and leave it at that?
My point is, with this example, it's difficult to show that this sentence structure is OK. Let's try something else:
The message was transmitted by varying the frequency of a communications laser
The message was transmitted through variations in the frequency of a communications laser
Hopefully, these both look fine to you? There may be more compact ways to say this, but none I can think of which use the passive voice. You could imagine either appearing in a scientific journal, where the passive voice is fairly standard.
With your other example
The children were evaluated by assigning them scores.
again, the problem is redundancy. "Assign scores" means more or less the same thing as "evaluate", and which is probably why you feel like something is off with the sentence. Otherwise it's fine, which you should be able to see with a different verb phrase:
The children were evaluated by comparing their respective weight-to-height ratios.
The children were evaluated through a comparison of their respective weight-to-height ratios.
Which is better depends on context. Although the first sentence is slightly less wordy, the second might be easier to understand.
[Edit] If you're still having trouble, trying changing these to the active voice and see if they look better. There should be little difference between the two, since the phrases in question are basically adverbial, and not the objects of the verb.
We evaluated the children by comparing their respective weight-to-height ratios.
Side note: Sources like Grammarly are unreliable because they flag the passive voice as "incorrect" based on common style guides for expository writing (although Grammarly does seem to now have various options, so that should help). Grade school teachers commonly tell young students not to use the passive voice because it weakens an argument -- if someone is doing something, then state that clearly. For example, rather than:
The bill was passed by an overwhelming majority
The committee passed the bill by an overwhelming majority
However this gives these students the impression that the passive voice is always wrong, which could not be farther from the truth. There are many contexts where the passive voice is preferred, especially in cases were you either don't want to or can't name the subject.
Although the actual sources are unclear, nevertheless the river has been polluted, and investigators say the malefactors will be brought to justice.
Still, it's better for young students (and ESL students) to avoid using the passive voice, at least until they understand when it is appropriate. Many may prefer it as a way of avoiding offending someone (as the passive might be more appropriate in their native language), but part of learning English involves understanding the preference (at least the American preference) for direct communication.