Zeebra commited on
Commit
84234c6
1 Parent(s): 18fadc0

initial Commit

Browse files
chatGPT_whisper_AI_voice_assistant/.gitignore ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by https://www.toptal.com/developers/gitignore/api/python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=python
3
+
4
+ ### Python ###
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/#use-with-ide
114
+ .pdm.toml
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
165
+
166
+ ### Python Patch ###
167
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168
+ poetry.toml
169
+
170
+ # ruff
171
+ .ruff_cache/
172
+
173
+ # LSP config files
174
+ pyrightconfig.json
175
+
176
+ # End of https://www.toptal.com/developers/gitignore/api/python
chatGPT_whisper_AI_voice_assistant/README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Voice Assistant with ChatGPT, Whisper API, Gradio, and TTS APIs
2
+ ===============================================================
3
+
4
+ My Voice Assistant is an AI-powered chatbot built with the collaboration of several APIs, including ChatGPT, Whisper API, Gradio, and Microsoft's SpVoice TTS API. It can understand natural language commands and provide helpful responses to various queries.
5
+
6
+ ![Screenshot (145)](https://user-images.githubusercontent.com/89584431/224185390-69c0e227-d88c-4612-aa4a-a130dcb76138.png)
7
+
8
+
9
+ Features
10
+ --------
11
+
12
+ The Voice Assistant is equipped with a wide range of features that can be accessed through voice commands. Here are some of the key features:
13
+
14
+ - Answering questions: The Voice Assistant can provide answers to general knowledge questions, such as "What is the capital of France?" or "What is the weather like in New York today?"
15
+
16
+ - Recommendations: The Voice Assistant can suggest movies, TV shows, books, and restaurants based on your preferences.
17
+
18
+ - Productivity: The Voice Assistant can perform tasks such as creating a to-do list or scheduling an appointment for your calendar.
19
+
20
+ - Entertainment: The Voice Assistant can write poems or tell jokes upon request.
21
+
22
+ Requirements
23
+ ------------
24
+
25
+ - Python 3.x
26
+ - Gradio
27
+ - ChatGPT API
28
+ - win32com (for Windows users only)
29
+
30
+ APIs Used
31
+ ---------
32
+
33
+ The Voice Assistant was built using the following APIs:
34
+
35
+ - ChatGPT: ChatGPT is a large language model trained by OpenAI that can understand natural language commands and provide helpful responses.
36
+
37
+ - Whisper API: Whisper API converts speech to text.
38
+
39
+ - Gradio: Gradio is a user interface API that allows users to interact with the Voice Assistant through a web-based interface.
40
+
41
+ - Microsoft's SpVoice TTS API: This API is used to provide text-to-speech functionality, allowing the Voice Assistant to speak responses out loud.
42
+
43
+ How to Use
44
+ ----------
45
+
46
+ To use the Voice Assistant, simply open the web-based interface provided by Gradio and click on the microphone button and speak to your assistant!. You can also edit your recorded questions to highlight the best parts. The Voice Assistant will listen to your commands and provide responses as needed.
47
+
48
+ Installation
49
+ ------------
50
+
51
+ 1. Clone the repository: `git clone https://github.com/DonGuillotine/chatGPT_whisper_AI_voice_assistant.git`
52
+ 2. Install the required Python packages: `pip install -r requirements.txt`
53
+ 3. Sign up for ChatGPT API key from <https://beta.openai.com/signup/>
54
+
55
+ Contributing
56
+ ------------
57
+
58
+ Contributions to this project are welcome. If you encounter any bugs or issues, please open an issue in the repository. If you would like to contribute code, please fork the repository and submit a pull request.
59
+
60
+ Conclusion
61
+ ----------
62
+
63
+ The Voice Assistant built with ChatGPT, Whisper API, Gradio, and Microsoft's SpVoice TTS API is a powerful tool that can help with a wide range of tasks, from answering general knowledge questions to scheduling appointments. It is easy to use and can be accessed through a web-based interface.
chatGPT_whisper_AI_voice_assistant/config.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ API_KEYS = {
2
+ 'openai':'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',
3
+ }
chatGPT_whisper_AI_voice_assistant/main.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import openai
3
+ from decouple import config
4
+ from gtts import gTTS
5
+ import os
6
+ import win32com.client
7
+ import pythoncom
8
+ import config
9
+
10
+ openai.api_key = config.API_KEYS['openai']
11
+
12
+ # The Models Job or role
13
+ messages = [
14
+ {"role": "system", "content": "You are a helpful assistant."},
15
+ ]
16
+
17
+
18
+ # language = 'en'
19
+
20
+
21
+ # Main method goes here
22
+ def decipher(audio):
23
+ global messages
24
+
25
+ # Using openAI's speech to text model
26
+ audio_file = open(audio, "rb")
27
+ transcript = openai.Audio.transcribe("whisper-1", audio_file)
28
+
29
+ messages.append({"role": "user", "content": transcript["text"]})
30
+
31
+ response = openai.ChatCompletion.create(
32
+ model="gpt-3.5-turbo",
33
+ messages=messages
34
+ )
35
+
36
+ system_message = response["choices"][0]["message"]["content"]
37
+ pythoncom.CoInitialize()
38
+ speaker = win32com.client.Dispatch("SAPI.SpVoice")
39
+ speaker.Speak(system_message)
40
+ # myobj = gTTS(text=system_message, lang=language, slow=False)
41
+ # myobj.save("welcome.mp3")
42
+ # # Playing the converted file
43
+ # os.system("start welcome.mp3")
44
+ messages.append({"role": "assistant", "content": system_message},)
45
+
46
+ chat_transcript = ""
47
+ for message in messages:
48
+ if message['role'] != 'system':
49
+ chat_transcript += message['role'] + ": " + message['content'] + "\n\n"
50
+
51
+ return chat_transcript
52
+
53
+
54
+ # Using Gradio's audio Interface
55
+ interface = gr.Interface(fn=decipher, inputs=gr.Audio(
56
+ source="microphone", type="filepath"), outputs="text")
57
+ interface.launch(share=True)
chatGPT_whisper_AI_voice_assistant/requirements.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.1.0
2
+ aiohttp==3.8.4
3
+ aiosignal==1.3.1
4
+ altair==4.2.2
5
+ anyio==3.6.2
6
+ async-timeout==4.0.2
7
+ attrs==22.2.0
8
+ certifi==2022.12.7
9
+ charset-normalizer==3.1.0
10
+ click==8.1.3
11
+ colorama==0.4.6
12
+ contourpy==1.0.7
13
+ cycler==0.11.0
14
+ entrypoints==0.4
15
+ fastapi==0.93.0
16
+ ffmpy==0.3.0
17
+ fonttools==4.39.0
18
+ frozenlist==1.3.3
19
+ fsspec==2023.3.0
20
+ gradio==3.20.1
21
+ gTTS==2.3.1
22
+ h11==0.14.0
23
+ httpcore==0.16.3
24
+ httpx==0.23.3
25
+ idna==3.4
26
+ Jinja2==3.1.2
27
+ jsonschema==4.17.3
28
+ kiwisolver==1.4.4
29
+ linkify-it-py==2.0.0
30
+ markdown-it-py==2.2.0
31
+ MarkupSafe==2.1.2
32
+ matplotlib==3.7.1
33
+ mdit-py-plugins==0.3.3
34
+ mdurl==0.1.2
35
+ multidict==6.0.4
36
+ numpy==1.24.2
37
+ openai==0.27.1
38
+ orjson==3.8.7
39
+ packaging==23.0
40
+ pandas==1.5.3
41
+ Pillow==9.4.0
42
+ pycryptodome==3.17
43
+ pydantic==1.10.6
44
+ pydub==0.25.1
45
+ pyparsing==3.0.9
46
+ pyrsistent==0.19.3
47
+ python-dateutil==2.8.2
48
+ python-decouple==3.8
49
+ python-multipart==0.0.6
50
+ pytz==2022.7.1
51
+ pywin32==305
52
+ PyYAML==6.0
53
+ requests==2.28.2
54
+ rfc3986==1.5.0
55
+ six==1.16.0
56
+ sniffio==1.3.0
57
+ starlette==0.25.0
58
+ toolz==0.12.0
59
+ tqdm==4.65.0
60
+ typing_extensions==4.5.0
61
+ uc-micro-py==1.0.1
62
+ urllib3==1.26.14
63
+ uvicorn==0.20.0
64
+ websockets==10.4
65
+ yarl==1.8.2