Created
March 26, 2016 08:32
-
-
Save imorrish/9135df9a6c4ffcc3dd10 to your computer and use it in GitHub Desktop.
Voice activated Blackmagic ATEM video switching
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
| # get SwitcherLib.dll from https://github.com/imorrish/atemlib | |
| add-type -path 'C:\Users\imorrish\Documents\WindowsPowerShell\Modules\ATEM\SwitcherLib.dll' | |
| $atem = New-Object SwitcherLib.Switcher("192.168.1.8") | |
| $atem.Connect() | |
| Write-host "ATEM Product: $($atem.GetProductName())" | |
| $preview = new-object SwitcherLib.Switcher+PreviewInput | |
| [Reflection.Assembly]::LoadWithPartialName("System.Speech") | Out-Null | |
| [Reflection.Assembly]::LoadWithPartialName("System.Globalization") | Out-Null | |
| $Command ={ | |
| if($Event.SourceArgs.Result.Confidence -gt .9){ | |
| $cmd=$Event.SourceArgs.Result.Text | |
| Write-Host "Executing command: $($cmd)" | |
| switch ($cmd) | |
| { | |
| "By" {$Global:listen = $false} | |
| "Cut" {$atem.Cut()} | |
| "Fade" {$atem.AutoTransition()} | |
| "One" {$preview.inputId = "1"} | |
| "Two" {$preview.inputId = "2"} | |
| "Three" {$preview.inputId = "3"} | |
| "Four" {$preview.inputId = "4"} | |
| "Five" {$preview.inputId = "5"} | |
| "Six" {$preview.inputId = "6"} | |
| "Seven" {$preview.inputId = "7"} | |
| "Eight" {$preview.inputId = "8"} | |
| "Nine" {$preview.inputId = "9"} | |
| } | |
| } | |
| Else | |
| { | |
| Write-Host "I think you said $($Event.SourceArgs.Result.Text) but not confident, try again." | |
| } | |
| } | |
| $CultureInfo = New-Object System.Globalization.CultureInfo("en-US") | |
| $SpeechRecognitionEngine = New-Object System.Speech.Recognition.SpeechRecognitionEngine($CultureInfo) | |
| $Texts = New-Object System.Speech.Recognition.Choices | |
| $Texts.Add("By") | |
| $Texts.Add("Cut") | |
| $Texts.Add("Fade") | |
| $Texts.Add("One") | |
| $Texts.Add("Two") | |
| $Texts.Add("Three") | |
| $Texts.Add("Four") | |
| $Texts.Add("Five") | |
| $Texts.Add("Six") | |
| $Texts.Add("Seven") | |
| $Texts.Add("Eight") | |
| $Texts.Add("Nine") | |
| $GrammarBuilder = New-Object System.Speech.Recognition.GrammarBuilder($Texts) | |
| $WordsList = New-Object System.Speech.Recognition.Grammar($GrammarBuilder) | |
| $SpeechRecognitionEngine.SetInputToDefaultAudioDevice() | |
| $SpeechRecognitionEngine.LoadGrammarAsync($WordsList) | |
| Unregister-Event "SpeechModuleCommandRecognized" -ErrorAction SilentlyContinue | |
| Register-ObjectEvent $SpeechRecognitionEngine SpeechRecognized -SourceIdentifier "SpeechModuleCommandRecognized" -Action $Command | Out-Null | |
| # start recognition | |
| $Global:listen = $true | |
| Write-Host "Listening for commands..." | |
| $RecognizeMode = New-Object System.Speech.Recognition.RecognizeMode | |
| $RecognizeMode.value__ = 1 # 0=Signle; 1=Multiple | |
| while($listen -eq $true) {$SpeechRecognitionEngine.Recognize()} | |
| Write-Host "no longer listening" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment