Skip to content

Instantly share code, notes, and snippets.

@dhaniksahni
Last active January 29, 2020 19:47
Show Gist options
  • Save dhaniksahni/3caf581b9a507c7ab8f411b08f2a6b4f to your computer and use it in GitHub Desktop.
Save dhaniksahni/3caf581b9a507c7ab8f411b08f2a6b4f to your computer and use it in GitHub Desktop.
<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>
({
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