简体   繁体   中英

Where is NSVoiceLocaleIdentifier on Xamarin.Mac?

I am aware that it is probably grouped with some other similar entities into some enum. But searching Google, searching assemblies returned no answers. So, where is NSVoiceLocaleIdentifier on Xamarin.Mac?

Note: There are "no" defined constants for compile time validation as the NSVoiceLocaleIdentifier strings are dynamic based upon your OS install. If you want a complete list, you have to look them up at application runtime.

NSVoice​Locale​Identifier is available within the NSDictionary that is returned for a particular voice.

No Serbian ( sv_SV ) on my system, but there are 64 others...

ie

  • com.apple.speech.synthesis.voice.Zarvox is USA English based ( en_US )
  • com.apple.speech.synthesis.voice.thomas is French ( fr-FR )

Example:

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();
}

Example Output:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM