以下代码:
AVSpeechSynthesizer * speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString: @"112"];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-GB"];
speechSynthesizer speakUtterance:utterance];
导致设备说:"一百和十二" (英国拼写)
但是,如果您改为音译112:
NSString * wordNumber = nil;
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en-GB"]];
[numberFormatter setNumberStyle:NSNumberFormatterSpellOutStyle];
wordNumber = [numberFormatter stringFromNumber:@(112)];
现在wordNumber包含"一百一十二" (没有和粒子)。
所以:
@"112" -> AVSpeechSynthesizer -> "one hundred and twelve"
@"112" -> NSNumberFormatter -> "one hundred twelve"
如何用和粒子音译数字,即英国拼写?
答案 0 :(得分:1)
我相信你自己需要这样做。我无法产生您想要的结果或找到任何允许我这样做的资源。
我已经链接到一个演示如何手动执行此操作的问题。
Is it possible to spell out numbers in words with a separator?
答案 1 :(得分:0)
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"112"];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-GB"];
NSString *transliteration = utterance.speechString;