<script src="https://astica.ai/javascript-sdk/2023-07-09/astica.api.js"></script>
<script>
//simple usage
function asticaListen_example() {
asticaListen('https://astica.ai/example/asticaListen_sample.wav');
}
setTimeout(function() {
asticaAPI_start('API KEY HERE'); //run at least once
asticaListen_example();
}, 2000);
//with parameters:
function asticaListen_Sample() {
var astica_modelVersion = '1.0_full';
var inputURL = 'https://www.astica.org/endpoint/ml/inputs/audio/sample_1.wav';
//With default callback:
asticaListen(astica_modelVersion, inputURL);
//With custom callback function:
asticaListen(astica_modelVersion, inputURL, your_astica_CallBack);
}
function your_astica_CallBack(data) {
if(typeof data.error != 'undefined') { alert(data.error); }
console.log(data); //view all data
}
setTimeout(function() {
asticaAPI_start('API KEY HERE'); //run at least once
asticaListen_Sample();
}, 1000);
</script>
asticaListen: Example #2 Local File Usage:
<script src="https://astica.ai/javascript-sdk/2023-07-09/astica.api.js"></script>
<script>
var asticaTranscribeFile_input = document.getElementById('astica_ML_voice_input');
var asticaTranscribeFile_localData;
var asticaTranscribeFile;
document.addEventListener("DOMContentLoaded", () => {
asticaTranscribeFile_input.addEventListener("change", function () {
asticaTranscribeFile = asticaTranscribeFile_input.files[0];
});
});
function asticaVoice_transcribeFile_test() {
asticaAPI_start(document.getElementById("astica_ML_apikey").value); //only needs to be called once.
asticaListen_file('1.0_full', asticaTranscribeFile, your_astica_CallBack);
}
function your_astica_CallBack(data) {
if(typeof data.error != 'undefined') { alert(data.error); return; }
console.log(data);
}
//view all data
</script>