Frequently Asked Question
How to use Text to Speech on iOS
Last Updated a year ago
This article shows how to use Text to Speech APIs:
In RDPDFViewController you can find OnSelEnd method that gives you the selected area, in this case you can reproduce the selected text with TTS APIs:
- (void)OnSelEnd:(float)x1 :(float)y1 :(float)x2 :(float)y2
{
if (m_bSel) {
// Get the selected Text
NSString *s = [m_view vSelGetText];
if(s)
{
// Initialize the TTS
AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc]init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:s];
// Set the speach speed
[utterance setRate:0.3f];
// Set the language
[utterance setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"]];
// Start playing
[synthesizer speakUtterance:utterance];
}
}
}