I have a working Powershell function that uses the System.Speech to read-out a random line from a text file, using the Get-Random cmdlet.
Unfortunately, the randomizer cmdlet doesn't seem to be doing such a good job by itself, as it repeats the same lines way too many times.
My text file contains just sentences.
function suggestion{
$suggestion=(Get-Random -InputObject (get-content C:\Tools\linesoftext.txt))
Add-Type -AssemblyName System.Speech
$synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$synth.Speak($suggestion)
}
I'm not sure if I can modify what I have, or rethink the way I'm trying to randomize the output--maybe by keeping track of what has been already played and loop? (I'm a bit stumped).
Aucun commentaire:
Enregistrer un commentaire