Skip to content

Commit

Permalink
import gtts and create convert and save audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikerniker committed May 22, 2024
1 parent d86f21b commit 47e7838
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Day91/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from flask import Flask, render_template, request, redirect, url_for, flash
from PyPDF2 import PdfReader
from gtts import gTTS


app = Flask(__name__)
app.config['SECRET_KEY'] = 'add-secret-key-here'
Expand All @@ -19,6 +21,12 @@ def get_pdf_text(pdf_file):
return all_text


def convert_and_save_audio(file):
pdf_text = get_pdf_text(file)
print(pdf_text)
text_to_speech = gTTS(pdf_text)
text_to_speech.save(f'{pdf_text}.mp3')

@app.route("/", methods=["GET", "POST"])
def home():
return render_template("index.html")
Expand Down

0 comments on commit 47e7838

Please sign in to comment.