in Education by
I have one weird requirement that in my existing app I have Text2Speech and for that, I have used AVSpeechSynthesizer to speech text, but now the requirement changed and now I need to convert HTML files data to text something like HTML2Speech. One Solution we can think: use HTML parsing and get all text from HTML and use same framework for Text2Speech. But the client doesn't want that type of parsing and he wants any API or framework which is providing directly HTML2Speech feature. Any suggestion or help will be highly appreciated. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
As I have worked with HTML parsing and text2speech here you can go with 2 steps 1.get Attribute string from HTML file with below code works in iOS7+ As per your client perspective : if there is any API in market for HTML2Speech may be its Paid or you are depended on that API if you use any. While Native framework will help same what you/client wants. Step 1: [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} documentAttributes:nil error:nil]; Then you can pass this Attributed String in AVSpeechUtterance Step 2: use below method to get HTML2String: /** * "ConvertHTMLtoStrAndPlay" : This method will convert the HTML to String synthesizer. * * @param aURLHtmlFilePath : "object of html file path" */ -(void)ConvertHTMLtoStrAndPlay:(UIButton*)aBtnPlayPause isSpeechPaused:(BOOL)speechPaused stringWithHTMLAttributes:(NSAttributedString*)aStrWithHTMLAttributes { if (synthesizer.speaking == NO && speechPaused == NO) { AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:aStrWithHTMLAttributes.string]; //utterance.rate = AVSpeechUtteranceMinimumSpeechRate; if (IS_ARABIC) { utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"ar-au"]; }else{ utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-au"]; } [synthesizer speakUtterance:utterance]; } else{ [synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate]; } if (speechPaused == NO) { [synthesizer continueSpeaking]; } else { [synthesizer pauseSpeakingAtBoundary:AVSpeechBoundaryImmediate]; } } and as usual while you need to stop use below code to stop Speech. /** * "StopPlayWithAVSpeechSynthesizer" : this method will stop the playing of audio on the application. */ -(void)StopPlayWithAVSpeechSynthesizer{ // Do any additional setup after loading the view, typically from a nib. [synthesizer stopSpeakingAtBoundary:AVSpeechBoundaryImmediate]; } Hope This will help you to get HTML2Speech feature.

Related questions

0 votes
    I use the vendor time picker component. Unfortunately, it uses rem units for most of its sizes, but ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    when two operators like+,- share the same ranking the formula is calculate from right to left. is it true or false? Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    Is it possible to model transitioning data like time-zone or a working directory? State reason behind your answer....
asked Oct 16, 2020 in Technology by JackTerrance
0 votes
    Is it possible to remove ( not hide using display:none ) some part of HTML from source for mobile ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 15, 2022 in Education by JackTerrance
0 votes
    It is possible to convert the existing HTML, CSS websites to hybrid apps using PhoneGap. Please select the correct options from below (a)False (b)True...
asked Dec 11, 2020 in Education by Editorial Staff
0 votes
    I'm trying to take the text from a ttk label and assign it to a variable, but I don't actually ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I'm trying to take the text from a ttk label and assign it to a variable, but I don't actually ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 13, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Can I catch multiple Java exceptions in the same catch clause? (10 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    What are two classes which are present in the Test Package by default? Is it possible for the developers or testers to modify the same?...
asked Feb 7, 2021 in Technology by JackTerrance
0 votes
    could it be possible to make a robot who is more efficient that humans? If yes, so what features would it ... more precise to work? Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    can anyone help me.. [NSString stringWithFormat:@"document.getElementsByTagName('body')[0].style.textAlign = ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    .controller('LoginCtrl', function($scope, $rootScope, $http, $state) { window.localStorage.removeItem("loggedIn"); ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I'm trying to change the color of text lines containing "Accepted" to green and all others to red ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    Why text inside / list is not affected (color of "item1", "item2" is not changed) by CSS applied ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 29, 2022 in Education by JackTerrance
...