using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CloudBuilder.AI.Policy { public enum ChineseTtsVoice { /// /// 普通话(中国大陆) 娇柔(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-0")] Sherpa0, /// /// 普通话(中国大陆)- 柔美(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 柔美(女性)-2")] Sherpa2, /// /// 普通话(中国大陆)- 知性(男性) /// [System.ComponentModel.Description("普通话(中国大陆) 知性(男性)-4")] Sherpa4, /// /// 普通话(中国大陆)- 知青(男性) /// [System.ComponentModel.Description("普通话(中国大陆) 知青(男性)-3")] Sherpa3, /// /// 普通话(中国大陆)- 中青(男性) /// [System.ComponentModel.Description("普通话(中国大陆) 中青(男性)-1")] Sherpa1, /// /// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快 /// [System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-6")] Aaishe6, /// /// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快 /// [System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-14")] Aaishe14, /// /// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快 /// [System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-18")] Aaishe18, /// /// 普通话(中国大陆)- 云健(男性)- 文件小速度快 /// [System.ComponentModel.Description("普通话(中国大陆) 云健(男性)-10")] Aaishe10, /// /// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快 /// [System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-1")] Aaishe1, /// /// 普通话(中国大陆)- 云健(男性)- 文件小速度快 /// [System.ComponentModel.Description("普通话(中国大陆) 云健(男性)-15")] Aaishe15, /// 普通话(中国大陆) 云阳(男性) /// [System.ComponentModel.Description("普通话(中国大陆) 云阳(男性)-10")] Fanchen10, /// /// 普通话(中国大陆) 云阳(男性) /// [System.ComponentModel.Description("普通话(中国大陆) 云阳(男性)-110")] Fanchen110, /// 普通话(中国大陆) 喜佳(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 云夏(女性)-6")] Fanchen6, /// /// 普通话(中国大陆) 云阳(男性) /// [System.ComponentModel.Description("普通话(中国大陆) 云阳(男性)-15")] Fanchen15, /// /// 普通话(中国大陆) 喜佳(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-2")] Fanchen2, /// /// 普通话(中国大陆) 喜佳(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-14")] Fanchen14, /// /// 普通话(中国大陆) 喜佳(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-20")] Fanchen20, /// /// 普通话(中国大陆) 喜佳(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-36")] Fanchen36, /// /// 粤语(香港)- 女性(男性)- 文件大 /// [System.ComponentModel.Description("粤语(香港) 梅隆 (女性)-0")] Melo, /// /// 普通话(中国大陆)- 神精女(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 神精女(女性)-0")] Eula, /// /// 普通话(中国大陆)- 小神精女(女性) /// [System.ComponentModel.Description("普通话(中国大陆) 小神精女(女性)-27")] Theresa, } public static class ChineseTtsVoiceRandom { private static readonly Random _random = new Random(); private static ChineseTtsVoice Default = ChineseTtsVoice.Sherpa2; private static ChineseTtsVoice DefaultFemale = ChineseTtsVoice.Sherpa0; private static ChineseTtsVoice DefaultMale = ChineseTtsVoice.Sherpa4; // 所有男性列表(只定义一次) private static readonly List _allMales = new() { ChineseTtsVoice.Sherpa4, ChineseTtsVoice.Sherpa3, ChineseTtsVoice.Sherpa1, ChineseTtsVoice.Aaishe10, ChineseTtsVoice.Aaishe15, ChineseTtsVoice.Fanchen10, ChineseTtsVoice.Fanchen110, ChineseTtsVoice.Fanchen15 }; // 所有女性列表 private static readonly List _allFemales = new() { ChineseTtsVoice.Sherpa0, ChineseTtsVoice.Sherpa2, ChineseTtsVoice.Aaishe6, ChineseTtsVoice.Aaishe14, ChineseTtsVoice.Aaishe18, ChineseTtsVoice.Aaishe1, ChineseTtsVoice.Fanchen6, ChineseTtsVoice.Fanchen2, ChineseTtsVoice.Fanchen14, ChineseTtsVoice.Fanchen20, ChineseTtsVoice.Fanchen36, ChineseTtsVoice.Melo, ChineseTtsVoice.Eula, ChineseTtsVoice.Theresa }; // 1. 随机取任意一个 public static ChineseTtsVoice GetRandom() { var all = Enum.GetValues(typeof(ChineseTtsVoice)).Cast().ToList(); return all[_random.Next(all.Count)]; } // 2. 随机女性 public static ChineseTtsVoice GetRandomFemale() { return _allFemales[_random.Next(_allFemales.Count)]; } // 3. 随机男性 public static ChineseTtsVoice GetRandomMale() { return _allMales[_random.Next(_allMales.Count)]; } // 4. 随机男性(传入要排除的声音,通用版 ✅) public static ChineseTtsVoice GetRandomMaleExclude(ChineseTtsVoice excludeVoice = ChineseTtsVoice.Sherpa4) { var filtered = _allMales.Where(m => m != excludeVoice).ToList(); return filtered[_random.Next(filtered.Count)]; } // 5. 随机女性(传入要排除的声音,通用版 ✅) public static ChineseTtsVoice GetRandomFemaleExclude(ChineseTtsVoice excludeVoice = ChineseTtsVoice.Sherpa0) { var filtered = _allFemales.Where(f => f != excludeVoice).ToList(); return filtered[_random.Next(filtered.Count)]; } // 1. 随机取任意一个 public static ChineseTtsVoice GetRandomExclude() { var all = Enum.GetValues(typeof(ChineseTtsVoice)).Cast().ToList(); all = all.Where(f => f != DefaultFemale && f != DefaultMale).ToList(); return all[_random.Next(all.Count)]; } } }