Add this section of code, where you want to show play button :
<!-- Play Button -->
<button onclick="readArticle()">▶ Play</button>
When you start a article section, then your code should look like this :
<!-- Blog Content -->
<div id="post-content">
<h2>My Blog Post Title</h2>
<p>This is a sample blog post. The play button should read this text aloud.</p>
</div>
Note : Just add this before your article start line : <div id="post-content">
Finally add this in your post or article section :
<!-- Text-to-Speech Script -->
<script>
function readArticle() {
let text = document.getElementById("post-content").innerText;
let speech = new SpeechSynthesisUtterance(text);
speech.lang = 'en-US'; // Change language if needed
speech.rate = 1.0; // Adjust speed (0.5 = slow, 2.0 = fast)
speech.pitch = 1.0; // Adjust pitch (0.5 = low, 2.0 = high)
window.speechSynthesis.speak(speech);
}
</script>
Now preview or publish your content and check if play button is showing and actually working or not.
You can check demo of this in my site here : https://www.bhudki.com/2025/03/how-to-add-faqs-in-blogger-website-page.html
0 Comments