Created
August 27, 2019 19:54
-
-
Save allenmichael/7f49ab39bef0f36d301321da28dd0879 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
$results = Get-Content -Path './transcribe/results.json' | ConvertFrom-Json | |
$items = $results.results.items | |
# only works on macOS | |
Start-Process afplay -ArgumentList @('./transcribe/cropped_podcast.mp3') -NoNewWindow | |
$counter = 1 | |
foreach ($item in $items) { | |
if ($item.end_time -lt $counter) { | |
if ($item.alternatives[0].content -eq '.') { | |
write-host -NoNewline $item.alternatives[0].content | |
Write-Host | |
} | |
else { | |
write-host -NoNewline "$($item.alternatives[0].content) " | |
} | |
} | |
else { | |
$counter++ | |
Start-Sleep -Seconds 1 | |
if ($item.alternatives[0].content -eq '.') { | |
write-host -NoNewline $item.alternatives[0].content | |
Write-Host | |
} | |
else { | |
write-host -NoNewline "$($item.alternatives[0].content) " | |
} | |
} | |
} |
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 | |
$podcastPath = "./transcribe/podcast.mp3" | |
$croppedPodcastPath = "./transcribe/cropped_podcast.mp3" | |
$resultsPath = "./transcribe/results.json" | |
foreach ($path in @($podcastPath, $croppedPodcastPath, $resultsPath)) { | |
if (Test-Path $path) { | |
Remove-Item $path | |
} | |
} | |
# https://d3gih7jbfe3jlq.cloudfront.net/aws-podcast.rss | |
$podcasts = Invoke-RestMethod https://d3gih7jbfe3jlq.cloudfront.net/aws-podcast.rss | select -ExpandProperty enclosure | select -ExpandProperty url | |
Invoke-WebRequest -Uri $podcasts[0] -OutFile $podcastPath | |
# using ffmpeg to crop podcast mp3 | |
ffmpeg -t 30 -i $podcastPath -acodec copy $croppedPodcastPath | |
Write-S3Object -BucketName livecoding -File $croppedPodcastPath | |
# replace with your bucket info | |
$bucket = 'livecoding' | |
$prefix = 'https://s3-us-west-2.amazonaws.com' | |
$s3uri = "$prefix/$bucket/cropped_podcast.mp3" | |
$jobName = "podcast-$(-join ((65..90) + (97..122) | Get-Random -Count 5 | % {[char]$_}))" | |
Write-Host "Creating job: $jobName" | |
Start-TRSTranscriptionJob -Media_MediaFileUri $s3uri -TranscriptionJobName $jobName -MediaFormat mp3 -LanguageCode en-US | |
$results = Get-TRSTranscriptionJob -TranscriptionJobName $jobName | |
while ($results.TranscriptionJobStatus -eq 'IN_PROGRESS') { | |
Start-Sleep -Seconds 5 | |
$results = Get-TRSTranscriptionJob -TranscriptionJobName $jobName | |
} | |
if ($results.TranscriptionJobStatus -eq 'COMPLETED') { | |
$transcripturi = $results.Transcript.TranscriptFileUri | |
Invoke-Webrequest -Uri $transcripturi -OutFile $resultsfile | |
} | |
if ($results.TranscriptionJobStatus -eq 'COMPLETED') { | |
$transcripturi = $results.Transcript.TranscriptFileUri | |
Invoke-Webrequest -Uri $transcripturi -OutFile $resultsPath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/serverlesspub/ffmpeg-aws-lambda-layer
This could work with the ffmpeg requirement