Created
October 15, 2019 18:14
-
-
Save cbattlegear/ee805737a7c5d49d1f94c24982e877d2 to your computer and use it in GitHub Desktop.
This file contains 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 _HeyMisty(data) { | |
misty.PlayAudio("s_PhraseHello.wav"); | |
//Record Voice Command | |
misty.StartRecordingAudio("VoiceCommand.wav"); | |
misty.Pause(3000); | |
misty.StopRecordingAudio(); | |
misty.Pause(1000); | |
//Check if Exists | |
misty.GetAudioList(); | |
_registerHeyMistyInteraction(); | |
} | |
//Callback function to check if voice command happened | |
function _GetAudioList(data) { | |
let containsNewFile = false; | |
var audioArr = data.Result; | |
for (let i = 0; i < audioArr.length; i++) { | |
if (audioArr[i].Name === "VoiceCommand.wav") { | |
containsNewFile = true; | |
} | |
} | |
if (containsNewFile) { | |
misty.GetAudioFile("VoiceCommand.wav", "_ProcessVoiceCommand"); | |
misty.PlayAudio("VoiceCommand.wav", 100, 500); | |
} | |
else { | |
misty.Debug("file was not found"); | |
} | |
} | |
//Use Base64 of wav to send to Azure Function | |
function _ProcessVoiceCommand(data) { | |
var voicecommand = data.Result; | |
var sound = {"SoundData": voicecommand.Base64}; | |
misty.SendExternalRequest("POST", "http://url/api/IntentDetection", null, null, JSON.stringify(sound), "true", "true", "responsevoice.wav", "audio/x-wav"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment