Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reverse engineered ChatGPT API #96

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions GPTResponder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import openai
from keys import OPENAI_API_KEY
from keys import OPENAI_API_KEY, ACCESS_TOKEN
from prompts import create_prompt, INITIAL_RESPONSE
import time

from revChatGPT.V1 import Chatbot
chatbot = Chatbot(config={
"access_token": f"{ACCESS_TOKEN}"
})
openai.api_key = OPENAI_API_KEY

def generate_response_from_transcript(transcript):
Expand All @@ -22,9 +25,10 @@ def generate_response_from_transcript(transcript):
return ''

class GPTResponder:
def __init__(self):
def __init__(self, revChatGPT):
self.response = INITIAL_RESPONSE
self.response_interval = 2
self.revChatGPT = revChatGPT

def respond_to_transcriber(self, transcriber):
while True:
Expand All @@ -33,7 +37,13 @@ def respond_to_transcriber(self, transcriber):

transcriber.transcript_changed_event.clear()
transcript_string = transcriber.get_transcript()
response = generate_response_from_transcript(transcript_string)
if self.revChatGPT:
for data in chatbot.ask(
create_prompt(transcript_string)
):
response = data["message"]
else:
response = generate_response_from_transcript(transcript_string)

end_time = time.time() # Measure end time
execution_time = end_time - start_time # Calculate the time it took to execute the function
Expand Down
47 changes: 33 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# 🎧 Ecoute

Ecoute is a live transcription tool that provides real-time transcripts for both the user's microphone input (You) and the user's speakers output (Speaker) in a textbox. It also generates a suggested response using OpenAI's GPT-3.5 for the user to say based on the live transcription of the conversation.
Expand All @@ -17,19 +16,24 @@ Follow these steps to set up and run Ecoute on your local machine.

- Python >=3.8.0
- An OpenAI API key that can access OpenAI API (set up a paid account OpenAI account)
- Or free ChatGPT Access Token (Get it here: https://chat.openai.com/api/auth/session)
- Windows OS (Not tested on others)
- FFmpeg
- FFmpeg

If FFmpeg is not installed in your system, you can follow the steps below to install it.

First, you need to install Chocolatey, a package manager for Windows. Open your PowerShell as Administrator and run the following command:

```
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```

Once Chocolatey is installed, you can install FFmpeg by running the following command in your PowerShell:

```
choco install ffmpeg
```

Please ensure that you run these commands in a PowerShell window with administrator privileges. If you face any issues during the installation, you can visit the official Chocolatey and FFmpeg websites for troubleshooting.

### 🔧 Installation
Expand All @@ -39,33 +43,38 @@ Please ensure that you run these commands in a PowerShell window with administra
```
git clone https://github.com/SevaSk/ecoute
```

2. Navigate to the `ecoute` folder:

```
cd ecoute
```

3. Install the required packages:

```
pip install -r requirements.txt
```

4. Create a `keys.py` file in the ecoute directory and add your OpenAI API key:

- Option 1: You can utilize a command on your command prompt. Run the following command, ensuring to replace "API KEY" with your actual OpenAI API key:

```
python -c "with open('keys.py', 'w', encoding='utf-8') as f: f.write('OPENAI_API_KEY=\"API KEY\"')"
```

```
python -c "with open('keys.py', 'w', encoding='utf-8') as f: f.write('OPENAI_API_KEY=\"API KEY\"')"
```
- Option 2: You can create the keys.py file manually. Open up your text editor of choice and enter the following content:

```
OPENAI_API_KEY="API KEY"
```
Replace "API KEY" with your actual OpenAI API key. Save this file as keys.py within the ecoute directory.

```
OPENAI_API_KEY="API KEY"
```

Replace "API KEY" with your actual OpenAI API key. Save this file as keys.py within the ecoute directory.
- Option 3: You can create the keys.py file manually. Open up your text editor of choice and enter the following content:

```
OPENAI_API_KEY="API KEY"
ACCESS_TOKEN="ACCESS TOKEN"
```

Keep `OPENAI_API_KEY="API KEY"`. And replace "ACCESS TOKEN" with your actual ChatGPT Access Token ([Get it here](https://chat.openai.com/api/auth/session)). Save this file as keys.py within the ecoute directory.

### 🎬 Running Ecoute

Expand All @@ -81,10 +90,18 @@ For a more better and faster version that also works with most languages, use:
python main.py --api
```

To use your free ChatGPT Access Token, use:

```
python main.py --revChatGPT
```

Upon initiation, Ecoute will begin transcribing your microphone input and speaker output in real-time, generating a suggested response based on the conversation. Please note that it might take a few seconds for the system to warm up before the transcription becomes real-time.

The --api flag will use the whisper api for transcriptions. This significantly enhances transcription speed and accuracy, and it works in most languages (rather than just English without the flag). It's expected to become the default option in future releases. However, keep in mind that using the Whisper API will consume more OpenAI credits than using the local model. This increased cost is attributed to the advanced features and capabilities that the Whisper API provides. Despite the additional expense, the substantial improvements in speed and transcription accuracy may make it a worthwhile investment for your use case.

The --revChatGPT will use the reverse engineered ChatGPT API from here: (https://github.com/acheong08/ChatGPT)

### ⚠️ Limitations

While Ecoute provides real-time transcription and response suggestions, there are several known limitations to its functionality that you should be aware of:
Expand All @@ -95,6 +112,8 @@ While Ecoute provides real-time transcription and response suggestions, there ar

**Language**: If you are not using the --api flag the Whisper model used in Ecoute is set to English. As a result, it may not accurately transcribe non-English languages or dialects. We are actively working to add multi-language support to future versions of the program.

**Free ChatGPT Access Token Limitation** If you are using the free ChatGPT Access Token, you will be limited to 5 requests per 10 seconds and 50 requests per hour for each account as outlined in the [revChatGPT Documentation](https://github.com/acheong08/ChatGPT#rate-limits)

## 📖 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def main():
transcribe.daemon = True
transcribe.start()

responder = GPTResponder()
responder = GPTResponder(revChatGPT=True) if '--revChatGPT' in sys.argv else GPTResponder(revChatGPT=False)
respond = threading.Thread(target=responder.respond_to_transcriber, args=(transcriber,))
respond.daemon = True
respond.start()
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ openai==0.27.6
customtkinter==5.1.3
PyAudioWPatch==0.2.12.5
--extra-index-url https://download.pytorch.org/whl/cu117
torch
torch
revChatGPT