From c57807924285220d90a4a122656f57eb30a3c629 Mon Sep 17 00:00:00 2001 From: GreevesW <138601558+GreevesW@users.noreply.github.com> Date: Wed, 19 Jul 2023 16:21:24 +0100 Subject: [PATCH 1/6] Update README.txt --- README.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.txt b/README.txt index 7c5f4ab..385c52e 100644 --- a/README.txt +++ b/README.txt @@ -19,7 +19,7 @@ ChatGPT prompt: API Keys: -Unique API keys for the chatGPT API and Aflorithmic Audiostack API are required for line 6 in chatgpt.py and line 12 in main.py respectively. These API keys can be imported or stored as libraries +Unique API keys for the chatGPT API and Aflorithmic Audiostack API are required for line 6 in chatgpt.py and line 12 in main.py respectively. These API keys can be imported or stored as privates. Installation: @@ -41,6 +41,5 @@ Troubleshooting: -Verify that the chatGPT API, audiostack API, and BeautifulSoup libary have been correctly installed. -verify that the chat From 63e2e2c2648fe889d7f4012471472feacf322995 Mon Sep 17 00:00:00 2001 From: GreevesW <138601558+GreevesW@users.noreply.github.com> Date: Wed, 19 Jul 2023 16:54:56 +0100 Subject: [PATCH 2/6] Add files via upload --- requirements.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3da38c3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,9 @@ +beautifulsoup4==4.9.3 +certifi==2020.12.5 +chardet==4.0.0 +idna==2.10 +requests==2.25.1 +soupsieve==2.2.1 +urllib3==1.26.4 +audiostack==0.0.9 +openai==0.27.8 From b6976856bcf9659a5f36a6265f99f98c49c0e4be Mon Sep 17 00:00:00 2001 From: GreevesW <138601558+GreevesW@users.noreply.github.com> Date: Thu, 20 Jul 2023 16:44:23 +0100 Subject: [PATCH 3/6] Update README.txt --- README.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/README.txt b/README.txt index 385c52e..0beb456 100644 --- a/README.txt +++ b/README.txt @@ -8,6 +8,7 @@ main.py chatgpt.py webscraper.py README.txt +requirements.txt The audio file will be saved as Summary.mp3 after the code has been run. From 11e1a887b9cd70a0049b7f74f093bb65ecb9af67 Mon Sep 17 00:00:00 2001 From: GreevesW <138601558+GreevesW@users.noreply.github.com> Date: Fri, 21 Jul 2023 09:59:20 +0100 Subject: [PATCH 4/6] Update chatgpt.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed £ and $ from validation routine in chatgpt.py and updated for loop. --- chatgpt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chatgpt.py b/chatgpt.py index 1627900..772f392 100644 --- a/chatgpt.py +++ b/chatgpt.py @@ -29,10 +29,10 @@ def generate_prompt(content): final = response.choices[0].text #Stores the text portion of the response from chatGPT in the variable final -originalchr = [ chr(34), chr(39), chr(194), "©", "$", "£", chr(92), "&"] -newchr = [ "", "", "", "", " dollars", " pounds", "", "and"] +originalchr = [ chr(34), chr(39), chr(194), "©", chr(92), "&"] +newchr = [ "", "", "", "", "", "and"] -for i in range(0,8): +for i in range(0,6): final = final.replace( originalchr[i], newchr[i]) print(final) From 78d685015e44d408d0adba142bb1bf5381eb73ad Mon Sep 17 00:00:00 2001 From: GreevesW <138601558+GreevesW@users.noreply.github.com> Date: Fri, 21 Jul 2023 10:00:16 +0100 Subject: [PATCH 5/6] Update webscraper.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit removed £ and $ from validation in webscraper.py and updated fro loop --- webscraper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webscraper.py b/webscraper.py index 807bdca..2dd34ec 100644 --- a/webscraper.py +++ b/webscraper.py @@ -16,11 +16,11 @@ #removes any invalid characters from the text content = newtext -originalchr = [ chr(34), chr(39), chr(194), "©", "$", "£", chr(92), "&"] -newchr = [ "", "", "", "", " dollars", " pounds", "", "and"] +originalchr = [ chr(34), chr(39), chr(194), "©", chr(92), "&"] +newchr = [ "", "", "", "", "", "and"] #replaces the invalid characters with the valid alternative in the newchr array -for i in range(0,8): +for i in range(0,6): content = content.replace( originalchr[i], newchr[i]) @@ -31,4 +31,4 @@ #print("The title is",title) -#Content is later imported into the chatgpt.py file to be used in the chatgpt prompt \ No newline at end of file +#Content is later imported into the chatgpt.py file to be used in the chatgpt prompt From a9065cd4753c22d8f591ae3f9b3e40c4d79dd56f Mon Sep 17 00:00:00 2001 From: GreevesW Date: Sat, 14 Feb 2026 00:28:21 +0000 Subject: [PATCH 6/6] updated README to md --- README.md | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 46 ----------------- 2 files changed, 142 insertions(+), 46 deletions(-) create mode 100644 README.md delete mode 100644 README.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..0f5fd08 --- /dev/null +++ b/README.md @@ -0,0 +1,142 @@ +# Web Scraper to Audio Summary + +A Python application that scrapes webpage content, generates a summary using ChatGPT, and converts it to an audio file using text-to-speech. + +## Overview + +This project automatically: +1. Scrapes text content from any webpage +2. Generates a concise summary using ChatGPT +3. Converts the summary to an MP3 audio file + +## How It Works + +### Workflow + +1. **webscraper.py** - Extracts webpage content + - Prompts user for a URL + - Uses BeautifulSoup to extract text from `` tags + - Validates and removes special characters (e.g., `©`, `&`) + - Passes cleaned content to ChatGPT module + +2. **chatgpt.py** - Generates summary + - Receives scraped content + - Sends content to ChatGPT API with custom prompt + - Returns AI-generated summary + +3. **main.py** - Creates audio file + - Receives ChatGPT summary + - Converts text to speech using Audiostack API + - Saves output as `Summary.mp3` + +## File Structure + +``` +. +├── main.py +├── chatgpt.py +├── webscraper.py +├── README.md +└── requirements.txt +``` + +## Installation + +### Prerequisites + +- Python 3.7+ +- OpenAI API key +- Audiostack API key + +### Setup Steps + +1. **Install ChatGPT requirements** + + Follow the [ChatGPT Quick Start Guide](https://platform.openai.com/docs/quickstart) for detailed instructions. + +2. **Install Audiostack SDK** + + ```bash + pip install -U audiostack + ``` + + or + + ```bash + pip3 install -U audiostack + ``` + + See [Audiostack SDK Quick Start](https://docs.audiostack.ai/docs/getting-started#quickstarts) for more information. + +3. **Install BeautifulSoup** + + ```bash + pip install beautifulsoup4 + ``` + +## Configuration + +### API Keys + +You'll need to configure API keys in the following locations: + +- **ChatGPT API**: Line 6 in `chatgpt.py` +- **Audiostack API**: Line 12 in `main.py` + +API keys can be stored as environment variables or imported as needed. + +### ChatGPT Prompt Settings + +The ChatGPT prompt can be customized with the following parameters: + +- **Temperature**: Controls randomness of the response +- **Max Tokens**: Set to 300 to ensure complete responses +- **Character Limit**: Response limited to 340 characters (produces ~30 second audio) + - Can be adjusted to any desired length + +## Usage + +1. Run the webscraper: + ```bash + python webscraper.py + ``` + +2. Enter the URL when prompted + +3. Wait for processing to complete + +4. Find your audio summary saved as `Summary.mp3` + +## Known Issues + +- Some webpages may cause errors if the ChatGPT response contains special characters incompatible with the Audiostack TTS model +- Characters like `\` or `|` may cause processing failures + +## Troubleshooting + +If you encounter errors: + +1. **Check ChatGPT output** - Verify the script doesn't contain unusual special characters (e.g., `\`, `|`) +2. **Verify installations** - Ensure all APIs and libraries are correctly installed: + - ChatGPT API + - Audiostack API + - BeautifulSoup library +3. **Test API keys** - Confirm both API keys are valid and properly configured + +## Output + +The final audio file will be saved as **Summary.mp3** in the project directory. + +## Dependencies + +- `beautifulsoup4` - Web scraping +- `openai` - ChatGPT API integration +- `audiostack` - Text-to-speech conversion + +## License + +[Add your license here] + +## Contributing + +[Add contribution guidelines here] \ No newline at end of file diff --git a/README.txt b/README.txt deleted file mode 100644 index 0beb456..0000000 --- a/README.txt +++ /dev/null @@ -1,46 +0,0 @@ -Explanation of the code: - -The webscraper.py file runs first and asks for the URL of a webpage to be entered. Using the beautiful soup module from the bs4 libary, the program gets all of the text between the body tags of the websites html file. Validation is then carried out using a for loop to remove any unusable special characters from the code ( such as "©" and "&"). The content between the body tags is then imported into the chatgpt.py file. The content is then inserted into a prewritten chatGPT prompt and the response is saved. The chatGPT response is then sent to the main.py file where it is saved as a script. The script is then compiled into a TTS audio file which is saved as Summary.mp3 . - -File list: - -main.py -chatgpt.py -webscraper.py -README.txt -requirements.txt - -The audio file will be saved as Summary.mp3 after the code has been run. - -ChatGPT prompt: - -- The temperature variable changes the randomness of the chatGPT response. -- The max tokens is set to 300 to ensure that a full response can be retrieved from chatGPT. -- The prompt asks ChatGPT to keep the response under 340 characters. This is done to keep the audio file under 30 seconds, but can be changed to any desired value. - -API Keys: - -Unique API keys for the chatGPT API and Aflorithmic Audiostack API are required for line 6 in chatgpt.py and line 12 in main.py respectively. These API keys can be imported or stored as privates. - -Installation: - -- follow the chat gpt quick start guide for information on how to install the requirements. https://platform.openai.com/docs/quickstart - -- The SDK for audiostack can be installed using the command -"pip install -U audiostack" or "pip3 install -U audiostack" -Audiostack SDK quick start: https://docs.audiostack.ai/docs/getting-started#quickstarts - -- Beautiful soup can be installed using the command "pip install beautifulsoup4" - -Known Bugs: - -- Some webpages may cause an error to occur if the chatGPT reply contains special characters wwhich cannot be used in the audiostack TTS model. - -Troubleshooting: - -- Check that the chatGPT script does not have any unusual special characters. (E.g. \ or | ) - --Verify that the chatGPT API, audiostack API, and BeautifulSoup libary have been correctly installed. - - -