Last active
January 29, 2020 19:47
-
-
Save dhaniksahni/3caf581b9a507c7ab8f411b08f2a6b4f 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
<aura:component controller="GoogleSpeechService" implements="lightning:isUrlAddressable,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" > | |
<aura:attribute name="recordId" type="String"/> | |
<lightning:card title="Google Transcription"> | |
<lightning:button variant="brand" label="Convert Audio to Text" title="Convert Audio to Text" onclick="{! c.translate }" /> | |
<lightning:textarea name="translatedText" label="" value="Transcript Placeholder" /> | |
</lightning:card> | |
</aura:component> |
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
({ | |
translate : function(component, event, helper) { | |
var recordId = component.get('v.recordId'); | |
var action = component.get("c.GetTranscript"); | |
action.setParams({ | |
"recordid": recordId | |
}); | |
action.setCallback(this, function(response){ | |
var status = response.getState(); | |
if(status === "SUCCESS"){ | |
var responseCode = response.getReturnValue(); | |
alert(JSON.stringify(responseCode)); | |
var result=responseCode.result; | |
var textVal=''; | |
for (i = 0; i < result.alternatives.length; i++) { | |
textVal += result.alternatives[i]; | |
} | |
alert(textVal); | |
} | |
}); | |
$A.enqueueAction(action); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment