Add record-mic.ps1

This commit is contained in:
Markus Fleschutz 2021-08-19 17:36:37 +02:00
parent 669af6ba99
commit 1d9693f565

26
Scripts/record-mic.ps1 Normal file
View File

@ -0,0 +1,26 @@
<#
.SYNOPSIS
record-mic.ps1 [<seconds>] [<path>]
.DESCRIPTION
Records audio from the microphone (WAV or MP3 format)
.EXAMPLE
PS> .\record-mic.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz
License: CC0
#>
param([int]$seconds = 10, [string]$path = "$HOME/mic.wav")
try {
Add-Type -Path PSCore.dll
$Recording = [PSCore.LoopbackRecorder] $Recording::StartRecording("$path")
Start-Sleep -s $seconds
$Recording::StopRecording()
exit 0
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}