Created
August 12, 2022 14:14
-
-
Save pstakuu/6312658827955341f70a3626afb9c54f to your computer and use it in GitHub Desktop.
allow you to record a message with sound recorder in windows, convert to mp3, upload to an auto-attendant in MSFT Teams; requires VLC
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
| function Set-AutoAttendantAudioFile { | |
| Param ( | |
| $originalAudioFile = "C:\Sound recordings\Recording (8).m4a", | |
| $autoAttendantName = “Teams Testing”, | |
| $VLCInstall = 'C:\Program Files\VideoLAN\VLC\vlc.exe' | |
| ) | |
| if (!(Test-Path $VLCInstall)) { | |
| "Need to install VLC or specify different install directory for VLC.exe" | |
| } | |
| function ConnectTo-Skype { | |
| $skypesession = New-CsOnlineSession | |
| Import-PSSession $skypesession | |
| } | |
| #check if any existing Skype session is broken - if so, remove it, unload the module, and reconnect | |
| $session = Get-PSSession | where name -match "sfb" | where state -eq "broken" | |
| if ($session) { | |
| Remove-PSSession $session | |
| get-module | where name -match "tmp" | Remove-Module | |
| ConnectTo-Skype | |
| } | |
| elseif (!((Get-Module | Where-Object name -match "tmp").ExportedCommands.'Import-CsOnlineAudioFile'.Name)) { | |
| ConnectTo-Skype | |
| } | |
| #gotta have VLC installed | |
| function ConvertToMp3( $file, [string] $vlc = 'C:\Program Files\VideoLAN\VLC\vlc.exe') { | |
| #from: https://timvw.be/2010/11/20/convert-aacm4a-files-to-mp3-with-vlc-and-powershell/ | |
| #adapted a bit to change the return value and Get-Item of $file | |
| PROCESS { | |
| $codec = 'mp3'; | |
| $oldFile = Get-Item $file; | |
| $newFile = $oldFile.FullName.Replace($oldFile.Extension, ".$codec"); | |
| &"$vlc" -I dummy "$oldFile" ":sout=#transcode{acodec=$codec,vcodec=dummy}:standard{access=file,mux=raw,dst=$newFile}" vlc://quit | out-null; | |
| return $newfile, ($oldfile.name -replace "\w\w\w$", "mp3") | |
| } | |
| } | |
| $outputFile, $fileBaseName = ConvertToMp3 -file $originalAudioFile | |
| $testingAttendant = Get-CsAutoAttendant -NameFilter $autoAttendantName | |
| $content = Get-Content $outputFile -encoding byte -ReadCount 0 | |
| $audiofile = Import-CsOnlineAudioFile -FileName $fileBaseName -Content $content -ApplicationId OrgAutoAttendant | |
| $audioFilePrompt = New-CsAutoAttendantPrompt -ActiveType AudioFile -AudioFilePrompt $audiofile -TextToSpeechPrompt "Your call is very important to us. Please select from the following options" | |
| $testingAttendant.DefaultCallFlow.Greetings[0] = $audioFilePrompt | |
| $res = Set-CsAutoAttendant -Instance $testingAttendant | |
| return $res | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment