by MacV

ReadAloud: URL to Speech Converter

Test this app for free
34
import logging
import os
from gunicorn.app.base import BaseApplication
from app_init import create_initialized_flask_app
from flask import request, jsonify, send_file
import requests
from bs4 import BeautifulSoup
from gtts import gTTS
import tempfile

# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()

# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

def scrape_article(url):
    try:
        response = requests.get(url)
        soup = BeautifulSoup(response.content, 'html.parser')
        
        # Remove script, style, nav, and footer elements
        for element in soup(["script", "style", "nav", "footer", "header"]):
Get full code

Created: | Last Updated:

A web app that converts news articles from URLs into speech using a text-to-speech API.

Here's a step-by-step guide for using the ReadAloud: URL to Speech Converter template:

Introduction

The ReadAloud: URL to Speech Converter is a web application that allows users to convert news articles from URLs into speech using a text-to-speech API. This template provides a simple interface for users to input article URLs and receive audio versions of the content.

Getting Started

To begin using this template:

  1. Click the "Start with this Template" button in the Lazy Builder interface.

Test the Application

Once you've started with the template:

  1. Click the "Test" button in the Lazy Builder interface.
  2. Wait for the application to deploy. The Lazy CLI will provide you with a dedicated server link to access the web interface.

Using the Application

After deployment, follow these steps to use the ReadAloud converter:

  1. Open the provided server link in your web browser.
  2. You'll see a simple interface with a form to input a URL.
  3. Paste the URL of the news article you want to convert into the input field.
  4. Click the "Read Article" button.
  5. The application will scrape the article, convert it to speech, and provide an audio player.
  6. Use the audio player controls to listen to the converted article.

How It Works

The application performs the following steps:

  1. Scrapes the provided URL for article content.
  2. Converts the scraped text to speech using the gTTS (Google Text-to-Speech) library.
  3. Provides an audio player for the user to listen to the converted content.

Customization

You can customize the application by modifying the following files:

  • templates/home.html: Adjust the HTML structure and layout of the main page.
  • static/css/styles.css: Modify the CSS to change the appearance of the application.
  • static/js/home.js: Update the JavaScript to alter the client-side functionality.

Conclusion

The ReadAloud: URL to Speech Converter template provides a straightforward way to convert web articles into audio format. It's ideal for users who prefer listening to content or need hands-free access to written articles.

Technologies

Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More Streamline CSS Development with Lazy AI: Automate Styling, Optimize Workflows and More
Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More Enhance HTML Development with Lazy AI: Automate Templates, Optimize Workflows and More
Enhance Your Projects with HTML, CSS, and JavaScript Templates Enhance Your Projects with HTML, CSS, and JavaScript Templates

Similar templates