startConversation method
Implementation
Future<String> startConversation(String lanRegion,bool useMic,{int samplerRate = 16000,int bitRate = 16,int channel = 1,bool autoTranslate = false,String fromLang = "",String toLang = "en"}) async {
this.autoTranslate = autoTranslate;
this.fromLang = fromLang;
this.toLang = toLang;
print("是否开启翻译:" + autoTranslate.toString());
Map<String, Object> map = {"useMic":useMic,"samplerRate": samplerRate,"bitRate":bitRate,"channel":channel,"lanRegion":lanRegion};
sessionStartedChannel.receiveBroadcastStream().listen(onSessionStartedEvent,onError:(err)=>print(err),cancelOnError: false);
sessionStoppedChannel.receiveBroadcastStream().listen(onSessionStoppedEvent,onError:(err)=>print(err),cancelOnError: false);
speechStartDetectedChannel.receiveBroadcastStream().listen(onSpeechStartDetectedEvent,onError:(err)=>print(err),cancelOnError: false);
speechEndDetectedChannel.receiveBroadcastStream().listen(onSpeechEndDetectedEvent,onError:(err)=>print(err),cancelOnError: false);
transcribedChannel.receiveBroadcastStream().listen((data)=>onTranscribedEvent(data["speakerId"],data["text"],data["offset"],data["duration"]),onError:(err)=>print(err),cancelOnError: false);
transcribingChannel.receiveBroadcastStream().listen((data)=>onTranscribingEvent(data["speakerId"],data["text"],data["offset"],data["duration"]),onError:(err)=>print(err),cancelOnError: false);
canceledChannel.receiveBroadcastStream().listen(onCanceledEvent,onError:(err)=>print(err),cancelOnError: false);
final result = await methodChannel.invokeMethod<String>('startConversation',map);
duringConversation = true;
loopCheckTranscribingChannelQueue();
loopCheckTranscribedChannelQueue();
return result ?? "Failed";
}