213 lines
7.9 KiB
C#
213 lines
7.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CloudBuilder.AI.Policy
|
|
{
|
|
public enum ChineseTtsVoice
|
|
{
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 娇柔(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-0")]
|
|
Sherpa0,
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 柔美(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 柔美(女性)-2")]
|
|
Sherpa2,
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 知性(男性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 知性(男性)-4")]
|
|
Sherpa4,
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 知青(男性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 知青(男性)-3")]
|
|
Sherpa3,
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 中青(男性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 中青(男性)-1")]
|
|
Sherpa1,
|
|
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-6")]
|
|
Aaishe6,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-14")]
|
|
Aaishe14,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-18")]
|
|
Aaishe18,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 云健(男性)- 文件小速度快
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 云健(男性)-10")]
|
|
Aaishe10,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 爱莎(女性)- 文件小速度快
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 爱莎(女性)-1")]
|
|
Aaishe1,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 云健(男性)- 文件小速度快
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 云健(男性)-15")]
|
|
Aaishe15,
|
|
|
|
/// 普通话(中国大陆) 云阳(男性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 云阳(男性)-10")]
|
|
Fanchen10,
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 云阳(男性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 云阳(男性)-110")]
|
|
Fanchen110,
|
|
/// 普通话(中国大陆) 喜佳(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 云夏(女性)-6")]
|
|
Fanchen6,
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 云阳(男性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 云阳(男性)-15")]
|
|
Fanchen15,
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 喜佳(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-2")]
|
|
Fanchen2,
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 喜佳(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-14")]
|
|
Fanchen14,
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 喜佳(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-20")]
|
|
Fanchen20,
|
|
/// <summary>
|
|
/// 普通话(中国大陆) 喜佳(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 喜佳(女性)-36")]
|
|
Fanchen36,
|
|
|
|
/// <summary>
|
|
/// 粤语(香港)- 女性(男性)- 文件大
|
|
/// </summary>
|
|
[System.ComponentModel.Description("粤语(香港) 梅隆 (女性)-0")]
|
|
Melo,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 神精女(女性)
|
|
/// </summary>
|
|
[System.ComponentModel.Description("普通话(中国大陆) 神精女(女性)-0")]
|
|
Eula,
|
|
|
|
/// <summary>
|
|
/// 普通话(中国大陆)- 小神精女(女性)
|
|
/// </summary>
|
|
[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<ChineseTtsVoice> _allMales = new()
|
|
{
|
|
ChineseTtsVoice.Sherpa4,
|
|
ChineseTtsVoice.Sherpa3,
|
|
ChineseTtsVoice.Sherpa1,
|
|
ChineseTtsVoice.Aaishe10,
|
|
ChineseTtsVoice.Aaishe15,
|
|
ChineseTtsVoice.Fanchen10,
|
|
ChineseTtsVoice.Fanchen110,
|
|
ChineseTtsVoice.Fanchen15
|
|
};
|
|
|
|
// 所有女性列表
|
|
private static readonly List<ChineseTtsVoice> _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<ChineseTtsVoice>().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<ChineseTtsVoice>().ToList();
|
|
all = all.Where(f => f != DefaultFemale && f != DefaultMale).ToList();
|
|
return all[_random.Next(all.Count)];
|
|
}
|
|
}
|
|
}
|