Xamarin.Mac 上的 NSVoiceLocaleIdentifier 在哪里?

Where is NSVoiceLocaleIdentifier on Xamarin.Mac?

我知道它可能与其他一些类似的实体组合到一些枚举中。但是搜索 Google,搜索程序集未返回任何答案。那么,Xamarin.Mac 上的 NSVoiceLocaleIdentifier 在哪里?

注意:"no" 定义了用于编译时验证的常量,因为 NSVoiceLocaleIdentifier 字符串是动态的,基于您的 OS 安装。如果你想要一个完整的列表,你必须在应用程序运行时查找它们。

NSVoice​Locale​Identifier 在针对特定语音返回的 NSDictionary 中可用。

我的系统上没有塞尔维亚语 (sv_SV),但还有 64 个其他...

  • com.apple.speech.synthesis.voice.Zarvox 是基于美国英语的 (en_US)
  • com.apple.speech.synthesis.voice.thomas 是法语 (fr-FR)

示例:

foreach (var voice in NSSpeechSynthesizer.AvailableVoices)
{
    Console.WriteLine(voice);
    var attributes = NSSpeechSynthesizer.AttributesForVoice(voice);
    foreach (var item in attributes)
    {
        if (item.Key.ToString() == "VoiceIndividuallySpokenCharacters" ||
            item.Key.ToString() == "VoiceSupportedCharacters")
            continue;
        Console.WriteLine($"\t{item.Key}:{item.Value}");
    }
    Console.WriteLine();
}

示例输出:

com.apple.speech.synthesis.voice.Zarvox
    VoiceShowInFullListOnly:1
    VoiceGender:VoiceGenderNeuter
    VoiceIdentifier:com.apple.speech.synthesis.voice.Zarvox
    VoiceVersion:3.6
    VoiceDemoText:That looks like a peaceful planet.
    VoiceLanguage:en-US
    VoiceAge:1
    VoiceName:Zarvox
    VoiceLocaleIdentifier:en_US

com.apple.speech.synthesis.voice.thomas
    VoiceName:Thomas
    VoiceGroup:VoiceGroupCompact
    VoiceLocaleIdentifier:fr_FR
    VoiceShowInFullListOnly:0
    VoiceDemoText:Bonjour, je m’appelle Thomas. Je suis une voix française.
    VoiceGender:VoiceGenderMale
    VoiceNumericID:251973347
    VoiceAge:35
    VoiceIdentifier:com.apple.speech.synthesis.voice.thomas
    VoiceVersion:5.0.7
    VoiceNameRoot:Thomas
    VoiceSynthesizerNumericID:1886745202
    VoiceRelativeDesirability:3800
    VoiceLanguage:fr-FR