public static async void translate(string text, int volume, int speed, int voiceType, TranslateCallback cb) { byte[] audioData = null; string err = null; try { TextToVoiceRequest req = new TextToVoiceRequest(); req.Text = text; req.SessionId = Convert.ToString(sessionId++); req.ModelType = 1; req.Volume = volume; req.Speed = speed; req.VoiceType = voiceType; req.Codec = "mp3"; TextToVoiceResponse res = await client.TextToVoice(req); audioData = Convert.FromBase64String(res.Audio); } catch (Exception e) { err = e.Message; } cb?.Invoke(text, audioData, err); }
public async Task <TextToVoiceResponse> TextToVoice(TextToVoiceRequest request) { var result = await _client.TextToVoice(request); return(result); }