2014-04-07 3 views
6

다음 코드 : 장치와의NSNumberFormatter :와 입자 (영국 철자)의 숫자를 맞춤법

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"가 포함됩니다.

그래서 :

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

은 어떻게 입자, 즉, 영국의 철자와 숫자를 음역 할 수 있습니까?

+0

'stringFromNumber'의 인수는 문자열 리터럴 대신'@ 112'이어야합니다. – blackbird

+0

가능한 중복 [구분 기호로 단어의 숫자를 철자 할 수 있습니까?] (http://stackoverflow.com/questions/12250126/is-it-possible-to-spell-out-numbers-in-words- a-separator) –

답변

1

본인이 직접해야한다고 생각합니다. 나는 원하는 결과를 산출하지 못했거나 그렇게 할 수있는 자원을 찾지 못했습니다.

이 작업을 수동으로 수행하는 방법을 보여주는 질문에 연결했습니다.

Is it possible to spell out numbers in words with a separator?

0

허, 당신은이 작업을 수행 할 수 있습니까?

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