Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of Html Widget with Text-to-Speech #609

Closed
smurat opened this issue Apr 5, 2021 · 2 comments
Closed

Usage of Html Widget with Text-to-Speech #609

smurat opened this issue Apr 5, 2021 · 2 comments

Comments

@smurat
Copy link

smurat commented Apr 5, 2021

I want to use flutter_tts package with Html Widget's data content. How can ignore the tags and only focus the meaningful data. Is there way flutter_html offer rendered output with cleaned string data or how can i achieve this.

@tneotia
Copy link
Collaborator

tneotia commented Apr 5, 2021

Possible duplicate of #270 , sorta kinda.

However you can clean the tags using the html parser from the html package the plugin uses: https://pub.dev/packages/html

You can use a loop to extract the text from each node and create your string to use flutter_tts.

@smurat
Copy link
Author

smurat commented Apr 7, 2021

This helped me.

import 'package:html/parser.dart';

//here goes the function 
String _parseHtmlString(String htmlString) {
final document = parse(htmlString);
final String parsedString = parse(document.body.text).documentElement.text;

return parsedString;
}

shot-out Jaswant Singh
from Stackoverflow

@smurat smurat closed this as completed Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants