Upon clicking a button, my save_data
method is triggered. This method includes a code snippet shown below:
save_recording(){
let formData = new FormData();
formData.append("id", id);
const transcript_arr = [];
const confidence_arr = [];
const service_transcript = this.ServiceTranscriptData();
const service_confidence = this.ServiceConfidenceData();
for (var i = 0; i < service_confidence.length; i++) {
// Code logic here
}
// More code goes here...
}
async ServiceTranscriptData() {
var trans = await this.service.getTranscriptValue();
return trans;
}
async ServiceConfidenceData() {
var confidence = await this.service.getConfidenceValue();
return confidence;
}
I want to ensure that the code following the lines this.ServiceTranscriptData()
and this.ServiceConfidenceData()
is not executed until these async functions complete their execution.
Currently, I am encountering an error:
Property length doesn't exist on type Promise<any[]>
. For reference, you can view the screenshots https://i.sstatic.net/9nuV9.png and https://i.sstatic.net/kHVJ3.png.
If you have any suggestions or solutions to resolve this issue, I would greatly appreciate it. Thank you!
Service :
import { Injectable } from '@angular/core';
declare var webkitSpeechRecognition: any;
@Injectable({
providedIn: 'root'
})
export class VoiceRecognitionService {
// Class implementation.
}