Exemplo n.º 1
0
 /// <summary>
 /// 开始一次语音合成,分配语音合成资源。
 /// </summary>
 /// <param name="param"></param>
 /// <param name="eCode"></param>
 /// <returns>sessionId</returns>
 public string TTSSessionBegin(TTSSessionBegin_Param param, ref int eCode)
 {
     try
     {
         var    paramJson = SerializeHelper.SerializeObjectToJson(param);
         var    paramStr  = paramJson.Replace(':', '=').Replace('"', ' ').Replace('{', ' ').Replace('}', ' ').Trim();
         var    intptr    = TTS_DLL.QTTSSessionBegin(paramStr, ref eCode);
         string sessioiId = ConvertHelper.IntPtrToString(intptr);
         return(sessioiId);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 初始化语音合成测试
 /// </summary>
 private void InitTTSConfig()
 {
     ttsSessionParam = new TTSSessionBegin_Param();
     speakers        = new List <Speaker> //初始化发音人列表
     {
         new Speaker()
         {
             Name = "小燕", Language = "普通话", Tone = "青年女声", Vname = "xiaoyan"
         },
         new Speaker()
         {
             Name = "燕平", Language = "普通话", Tone = "青年女声", Vname = "yanping"
         },
         new Speaker()
         {
             Name = "晓婧", Language = "普通话", Tone = "青年女声", Vname = "jinger"
         },
         new Speaker()
         {
             Name = "晓峰", Language = "普通话", Tone = "青年男声", Vname = "xiaofeng"
         },
         new Speaker()
         {
             Name = "晓琳", Language = "台湾普通话", Tone = "青年女声", Vname = "xiaolin"
         },
         new Speaker()
         {
             Name = "晓倩", Language = "东北话", Tone = "青年女声", Vname = "xiaoqian"
         },
         new Speaker()
         {
             Name = "晓蓉", Language = "四川话", Tone = "青年女声", Vname = "xiaorong"
         },
         new Speaker()
         {
             Name = "小坤", Language = "河南话", Tone = "青年男声", Vname = "xiaokun"
         },
         new Speaker()
         {
             Name = "小强", Language = "湖南话", Tone = "青年男声", Vname = "xiaoqiang"
         },
         new Speaker()
         {
             Name = "晓美", Language = "粤语", Tone = "青年女声", Vname = "xiaomei"
         },
         new Speaker()
         {
             Name = "大龙", Language = "粤语", Tone = "青年男声", Vname = "dalong"
         }
     };
     this.comboBox1.DataSource   = speakers.Select(p => p.Language).Distinct().ToArray();
     this.comboBox1.SelectedItem = speakers.Find(p => p.Vname.Equals(ttsSessionParam.voice_name)).Language;
     this.comboBox2.DataSource   = speakers.Where(p => p.Language.Equals(this.comboBox1.SelectedItem)).Select(p => p.Tone).Distinct().ToArray();
     this.comboBox2.SelectedItem = speakers.Find(p => p.Vname.Equals(ttsSessionParam.voice_name)).Tone;
     this.comboBox3.DataSource   = speakers.Where(p => p.Language.Equals(this.comboBox1.SelectedItem) && p.Tone.Equals(this.comboBox2.SelectedItem)).Select(p => p.Name).Distinct().ToArray();
     this.comboBox3.SelectedItem = speakers.Find(p => p.Vname.Equals(ttsSessionParam.voice_name)).Name;
     this.comboBox4.DataSource   = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
     this.comboBox4.SelectedItem = 50;
     this.comboBox5.DataSource   = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
     this.comboBox5.SelectedItem = 50;
     this.comboBox6.DataSource   = new int[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
     this.comboBox6.SelectedItem = 50;
 }