-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace API endpoint and speech synthesizer #418
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me apart from one or two small things to adjust.
Thanks for sorting this out! 💖 😊
"\t$SpeechSynth = New-Object -ComObject SAPI.SpVoice", | ||
"\t$URI = 'https://catfact.ninja/fact'", | ||
"\t$CatFact = Invoke-WebRequest -Uri $URI | ConvertFrom-Json | Select-Object -ExpandProperty fact", | ||
"\t$SpeechSynth.Speak(\"Did you know? $Catfact\") | Out-Null", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnheusinger can you add a note into either the code segment (as a comment) or into the above description mentioning this is Windows-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🙂
"\t$SpeechSynth.Speak($CatFact.details)", | ||
"\t$SpeechSynth = New-Object -ComObject SAPI.SpVoice", | ||
"\t$URI = 'https://catfact.ninja/fact'", | ||
"\t$CatFact = Invoke-WebRequest -Uri $URI | ConvertFrom-Json | Select-Object -ExpandProperty fact", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"\t$CatFact = Invoke-WebRequest -Uri $URI | ConvertFrom-Json | Select-Object -ExpandProperty fact", | |
"\t$CatFact = Invoke-RestMethod -Uri $URI | Select-Object -ExpandProperty fact", |
IRM does a direct JSON conversion for this purpose 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And done. Thanks 🙂
PR Summary
I noticed that the 'Fun with Cat Facts' advice snippet referenced a REST API that is no longer available. I found a replacement API and made some adjustments so that the result matches the original intention.
I also noticed that the example makes use of System.Speech which works on Windows PowerShell but not PowerShell Core. I switched to the SAPI.SpVoice COM object which is also compatible with PS Core.
Context
Relates to #260
Changes
Checklist