Knowledge Base - How to use Text to Speech

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];

        }

        

    }

 

}

Applies To

RadaeePDF SDK for iOS

Details

Created : 2017-10-02 15:49:10, Last Modified : 2017-10-02 15:52:08

Order history

Login to handle your order history.