jakecyr / chatgpt-voice-assistant Goto Github PK
View Code? Open in Web Editor NEWA chatbot that integrates OpenAI Whisper, Chat Completions and Voice Generation. Also provides the option to use free transcription / TTS options.
A chatbot that integrates OpenAI Whisper, Chat Completions and Voice Generation. Also provides the option to use free transcription / TTS options.
After refactoring all of the classes to follow design principles the unit tests are broken.
Add an option to choose OpenAI Whisper for speech to text instead of Google's free API.
Add support to set the output voice language accent with CLI parameters.
Add an option to set a wake word for commands / requests to avoid everything said being sent to OpenAI which will drive up API costs.
We currently have a safe_word
option to exit a chat. We can do something similar, but with a wake_word
. An extra parameter can be added to the "conversation.py" constructor wake_word
.
OpenAI created an new chat completions endpoint that has a better trained model for chat related tasks.
Update the OpenAI client to use ChatCompletion instead of Completion to use the model optimized for chatting. Send the history o the user / model interactions with each request.
Make sure the safe_word is not None
before using it:
https://github.com/jakecyr/openai-gpt3-chatbot/blob/master/gpt3_assistant/conversation.py#L41
Refactor code base to follow best practices including SOLID design principles.
The current test coverage is 66% when including all files (even those untouched by tests).
To check the coverage, run the following:
coverage run --source chatgpt_voice_assistant -m pytest tests
coverage report --show-missing # or `coverage html` to generate an HTML website to view the test coverage line by line
We should increase the level of test coverage to ensure there are no regressions when adding or changing code.
Cloned repo, followed instructions in the readme, and ran program. It listens to the command, but it throws the following error right after.
INFO:root:Listening for input with mic 'MacBook Pro Microphone'...
INFO:root:Speech: top 10 movies on IMDb
INFO:openai:error_code=None error_message='This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?' error_param=model error_type=invalid_request_error message='OpenAI API error received' stream_error=False
Traceback (most recent call last):
File "code/github/chatgpt-voice-assistant/chatgpt_voice_assistant/main.py", line 79, in
main()
File "code/github/chatgpt-voice-assistant/chatgpt_voice_assistant/main.py", line 75, in main
conversation.start_conversation()
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/chatgpt_voice_assistant/conversation.py", line 83, in start_conversation
response = self._text_generator.generate_text(text)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/chatgpt_voice_assistant/open_ai_text_generator.py", line 28, in generate_text
exchange: Exchange = self._open_ai_client.get_completion(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/chatgpt_voice_assistant/clients/open_ai_client.py", line 35, in get_completion
completion = openai.Completion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/openai/api_resources/completion.py", line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File "~/code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/openai/api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/openai/api_requestor.py", line 620, in _interpret_response
self._interpret_response_line(
File "code/github/chatgpt-voice-assistant/env/lib/python3.11/site-packages/openai/api_requestor.py", line 683, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.