mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-23 18:38:19 +02:00
Add record-mic.ps1
This commit is contained in:
parent
669af6ba99
commit
1d9693f565
26
Scripts/record-mic.ps1
Normal file
26
Scripts/record-mic.ps1
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user