From 1cc2d8a1af147fb9a92780c7cfb2fd4a0197c5b4 Mon Sep 17 00:00:00 2001 From: Josh King Date: Fri, 21 Apr 2023 17:25:50 +1200 Subject: [PATCH 1/2] (fix) Speak function throwing exception enumerating voices Moves the creation of the `SAPI.SpVoice` object above selection of the voice, as there's currently an error thrown when running this function due to the object not yet existing. --- Functions/Speak.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Functions/Speak.md b/Functions/Speak.md index 4435b6d..900c549 100644 --- a/Functions/Speak.md +++ b/Functions/Speak.md @@ -45,8 +45,8 @@ param ( [string]$Sentence ) -$s.Voice = $s.GetVoices().Item(0) $s=New-Object -ComObject SAPI.SpVoice +$s.Voice = $s.GetVoices().Item(0) $s.Rate = -2 $s.Speak($Sentence) } From f39db92a93f959bd6a20bc30c0de7c265d74f038 Mon Sep 17 00:00:00 2001 From: Josh King Date: Fri, 21 Apr 2023 17:31:28 +1200 Subject: [PATCH 2/2] (maint) Supress output from Speak method The `Speak` method returns a number which is used when "speaking" asynchronously. As a user, the number is meaningless and via this function it will always be `1`. This assigns the output to `null` so that there is no output from the function. --- Functions/Speak.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Functions/Speak.md b/Functions/Speak.md index 900c549..d8d4208 100644 --- a/Functions/Speak.md +++ b/Functions/Speak.md @@ -48,7 +48,7 @@ param ( $s=New-Object -ComObject SAPI.SpVoice $s.Voice = $s.GetVoices().Item(0) $s.Rate = -2 -$s.Speak($Sentence) +$null = $s.Speak($Sentence) } ```