5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AVSpeechSynthesizerの読み上げ速度は、iOSのバージョンによって異なる

Last updated at Posted at 2016-07-01

普通、同じでしょうと思うかもしれませんが、違ったので備忘録的な感じで書いておきます。

- (void)speechTest {
	//初期化
	AVSpeechSynthesizer* speechSynthesizer = [[AVSpeechSynthesizer alloc] init];  

	AVSpeechUtterance *utterance = [AVSpeechUtterance 	speechUtteranceWithString:@"ほげほげ"];

	//言語指定
	AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ja-JP"];

	//iOS8の読み上げ速度のみ極端に速いので分岐処理
	if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_8_3) { 
		//iOS9
		speech.rate = 0.5f; //Max 1.0 - Min 0.1
	} else if(floor(NSFoundationVersionNumber) > 	NSFoundationVersionNumber_iOS_7_1) { 
    	//iOS8
		speech.rate = 0.05f; //Max 0.1 - Min 0.01?
	} else { 
   		//iOS7
   		speech.rate = 0.5f; //Max 1.0 - Min 0.1
	}
	
	[speechSynthesizer speakUtterance:utterance];  

}

最初、Max1.0からMin0.1が設定範囲だと思い、標準の0.5で読み上げ速度を設定していました。
ですが、iOS8の端末のみ極端に読み上げ速度が速くなってしまったので軽く調べてみるとiOSのバージョンによって読み上げ速度が違っていたようです。
iOS9、iOS7のレートは同じにしていますが、厳密には少し速度が違うみたいなので微調整は必須でしょう。

とにかくiOS8を含んでかつ、AVSpeechSynthesizerを使うときは注意です。

参考元
http://tokentoken.com/blog/2015/09/avspeechsynthesizer/

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?