NSNumberFormatter: Determining a Number Using AND (English Spelling)

The following code:

AVSpeechSynthesizer * speechSynthesizer = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString: @"112"]; utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-GB"]; speechSynthesizer speakUtterance:utterance]; 

causes the device to say: β€œone hundred and twelve” (English spelling)

But if you transliterate number 112 instead:

 NSString * wordNumber = nil; NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; [numberFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en-GB"]]; [numberFormatter setNumberStyle:NSNumberFormatterSpellOutStyle]; wordNumber = [numberFormatter stringFromNumber:@(112)]; 

now wordNumber contains "one hundred and twelve" (without particles and particles).

So:

 @"112" -> AVSpeechSynthesizer -> "one hundred and twelve" @"112" -> NSNumberFormatter -> "one hundred twelve" 

How can I transliterate a number with and particles, i.e. English spelling?

+6
source share
2 answers

I believe that you will need to do it yourself. I could not get the desired result or find any resource that allows me to do this.

I contacted a question that shows how to do this manually.

Is it possible to specify numbers in words with a separator?

+1
source

Can't you do it?

 AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"112"]; utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-GB"]; NSString *transliteration = utterance.speechString; 
0
source

All Articles