Skip to content

Commit

Permalink
Create Main
Browse files Browse the repository at this point in the history
  • Loading branch information
PC65049955 authored Dec 14, 2022
1 parent c3bddd8 commit 1874589
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Main
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
from pydub import AudioSegment

# Convert PDF to text
# This step will depend on which libraries you have installed
# and which format your PDF is in.
# You may need to use a different approach to convert your PDF
# to text.
pdf_text = convert_pdf_to_text(pdf_file)

# Split text into sentences
sentences = split_text_into_sentences(pdf_text)

# Create an audio file for each sentence
for sentence in sentences:
sentence_audio = create_audio_from_text(sentence)

# Save audio file
sentence_audio.export(os.path.join(output_dir, sentence + ".mp3"))

# Combine all audio files into a single audiobook
combined_audio = AudioSegment.empty()
for sentence in sentences:
sentence_audio = AudioSegment.from_mp3(os.path.join(output_dir, sentence + ".mp3"))
combined_audio += sentence_audio

combined_audio.export(os.path.join(output_dir, "audiobook.mp3"))

0 comments on commit 1874589

Please sign in to comment.