Last active
August 27, 2019 19:52
-
-
Save allenmichael/6ddaa93107a3ea69317a7467ed1fd703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module AWSPowerShell.NetCore | |
$fileOrHost = Read-Host "Read from terminal[1] or file[2] (1 or 2)?" | |
if ("1", "2" -notcontains $fileOrHost ) { | |
$fileOrHost = "1" | |
} | |
$text = "" | |
if ($fileOrHost -eq "1") { | |
$text = Read-Host "Enter text to be redacted." | |
} | |
$lang = Find-COMPDominantLanguage -Text $text | |
$syntax = Find-COMPSyntax -Text $text -LanguageCode $lang.LanguageCode | |
$words = $syntax | | |
Where-Object { | |
$_.PartOfSpeech.Tag -eq "PROPN" -or | |
$_.PartOfSpeech.Tag -eq "NOUN" | |
} | |
# -or $_.PartOfSpeech.Tag -eq "PRON" | |
foreach ($word in $words) { | |
$chars = ($word.EndOffset - $word.BeginOffset) | |
$text = $text.Remove($word.BeginOffset, $chars) | |
$filler = "x" * $chars | |
$text = $text.Insert($word.BeginOffset, $filler) | |
} | |
Write-Host $text | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module AWSPowerShell.NetCore | |
$location = Get-Location | |
$path = $($location.tostring() + "/polly/rss.mp3") | |
$txtPath = $($location.tostring() + "/polly/rss.txt") | |
function Get-NextBlog() { | |
$continue = Read-Host "Read a blog description? (y/n)" | |
while ("y", "n" -notcontains $continue ) { | |
$continue = Read-Host "Read a blog description? (y/n)" | |
} | |
return $continue | |
} | |
$doc = Invoke-RestMethod http://feeds.feedburner.com/AmazonWebServicesBlog?fmt=xml | |
if (Test-Path $txtPath) { | |
Remove-Item $txtPath | |
} | |
$doc | Out-File $txtPath | |
$blogsDescribed = 0 | |
$continue = Get-NextBlog | |
while ($continue -ne 'n') { | |
$text = $doc[$blogsDescribed].description | |
$speech = Get-POLSpeech -VoiceId Nicole -Text $text -OutputFormat mp3 | |
Write-Host "Got here" | |
if (Test-Path $path) { | |
Remove-Item $path | |
} | |
Write-Host "past check" | |
$location = Get-Location | |
Write-Host $location | |
$fs = [System.IO.FileStream]::new($path, [System.IO.FileMode]::CreateNew) | |
$speech.AudioStream.CopyTo($fs) | |
$fs.Close() | |
afplay $path | |
$blogsDescribed += 1 | |
if ($doc.Length -le $blogsDescribed) { | |
break; | |
} | |
else { | |
$continue = Get-NextBlog | |
} | |
} | |
Write-Host "Thanks for listening!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment