From 8063f4b08fc336ac685e229231af7833c8aa1446 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 17 Jul 2021 14:57:22 +0200 Subject: [PATCH] Improve list-voices.ps1 --- Scripts/list-voices.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Scripts/list-voices.ps1 b/Scripts/list-voices.ps1 index 3d8c5bc7..152ff0dc 100644 --- a/Scripts/list-voices.ps1 +++ b/Scripts/list-voices.ps1 @@ -11,13 +11,15 @@ Author: Markus Fleschutz / License: CC0 #> +#requires -Version 2.0 + try { - $Voice = new-object -ComObject SAPI.SPVoice - $Voices = $Voice.GetVoices() - foreach ($OtherVoice in $Voices) { - $Description = $OtherVoice.GetDescription() - "* $Description" - } + add-type -AssemblyName System.Speech + $speak = New-Object System.Speech.Synthesis.SpeechSynthesizer + $speak.GetInstalledVoices() | + Select-Object -ExpandProperty VoiceInfo | + Select-Object -Property Name, Culture, Gender, Age + exit 0 } catch { write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"