loopCheckTranscribedChannelQueue method

void loopCheckTranscribedChannelQueue()

Implementation

void loopCheckTranscribedChannelQueue() async{
  while(duringConversation){
    if(transcribedChannelQueue.isNotEmpty){
      var obj = transcribedChannelQueue.removeFirst();
      var result = await translate(obj.text, fromLang, toLang);
      if(result != null){
        try{
          var data = JsonDecoder().convert(result);
          azureSttCallback.onTranscribedEvent(obj.speakerId,obj.text,data[0]["translations"][0]["text"],2,true,obj.speechStartTimeStamp,obj.speechEndTimeStamp,DateTime.now().millisecondsSinceEpoch);
        }
        catch(ex){
          azureSttCallback.onTranscribedEvent(obj.speakerId,obj.text,"",2,false,obj.speechStartTimeStamp,obj.speechEndTimeStamp,DateTime.now().millisecondsSinceEpoch);
        }
      }
      else{
        azureSttCallback.onTranscribedEvent(obj.speakerId,obj.text,"",2,false,obj.speechStartTimeStamp,obj.speechEndTimeStamp,DateTime.now().millisecondsSinceEpoch);
      }
    }
    else{
      await Future.delayed(Duration(milliseconds: 50));
    }
  }
}