markdown-to-speech is a Python tool that converts Markdown text into high-quality voiceovers using OpenAI's text-to-speech API. This tool is ideal for creating professional audio content from structured text files.
- Converts Markdown files to plain text.
- Generates speech in MP3 format using OpenAI's text-to-speech API.
- Customizable voice and tone settings.
- Automatically timestamps filenames to prevent overwriting.
- Python 3.8 or higher
- OpenAI Python SDK
- Required Python libraries:
html2text
markdown
python-dotenv
-
Clone the repository:
git clone https://github.com/your-username/markdown-to-speech.git cd markdown-to-speech
-
Install dependencies:
pip install -r requirements.txt
-
Set up your OpenAI API key:
- Create a
.env
file in the project root. - Add the following line to the
.env
file:OPENAI_API_KEY=your_api_key_here
- Create a
-
Place your Markdown content in the
input_markdown.md
file. -
Run the script:
python generate_speech.py
-
The generated MP3 file will be saved in the
voiceovers
directory with a timestamped filename.
You can customize the following settings in generate_speech.py
:
- Section Name: Change the
section_name
variable to include a specific section name in the filename. - Voice: Modify the
voice
variable to use a different voice model (e.g.,onyx
,jade
, etc.). - Instructions: Update the
instructions
variable to adjust the tone and style of the speech.
After running the script, you will see a confirmation message:
✅ Speech saved as: voiceovers/intro_2025-05-30_14-45.mp3
This project is licensed under the MIT License. See the LICENSE
file for details.
Feel free to submit issues or pull requests to improve this tool!
markdown-to-speech is a Python tool that converts Markdown text into high-quality voiceovers using OpenAI's text-to-speech API. This tool is ideal for creating professional audio content from structured text files.
## Features
- Converts Markdown files to plain text.
- Generates speech in MP3 format using OpenAI's text-to-speech API.
- Customizable voice and tone settings.
- Automatically timestamps filenames to prevent overwriting.
## Requirements
- Python 3.8 or higher
- OpenAI Python SDK
- Required Python libraries:
- `html2text`
- `markdown`
- `python-dotenv`
## Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/markdown-to-speech.git
cd markdown-to-speech
-
Install dependencies:
pip install -r requirements.txt
-
Set up your OpenAI API key:
- Create a
.env
file in the project root. - Add the following line to the
.env
file:OPENAI_API_KEY=your_api_key_here
- Create a
-
Place your Markdown file in the project directory and name it
input_markdown.md
. -
Run the script:
python generate_speech.py
-
The generated MP3 file will be saved in the
voiceovers
directory with a timestamped filename.
You can customize the following settings in generate_speech.py
:
- Section Name: Change the
section_name
variable to include a specific section name in the filename. - Voice: Modify the
voice
variable to use a different voice model (e.g.,onyx
,jade
, etc.). - Instructions: Update the
instructions
variable to adjust the tone and style of the speech.
After running the script, you will see a confirmation message:
✅ Speech saved as: voiceovers/intro_2025-05-30_14-45.mp3
Feel free to submit issues or pull requests to improve this tool!