Coder Social home page Coder Social logo

jakecyr / chatgpt-voice-assistant Goto Github PK

View Code? Open in Web Editor NEW
115.0 115.0 28.0 415 KB

A chatbot that integrates OpenAI Whisper, Chat Completions and Voice Generation. Also provides the option to use free transcription / TTS options.

Python 100.00%
artificial-intelligence chatgpt machine-learning python voice-assistant voice-recognition

chatgpt-voice-assistant's People

Contributors

jakecyr avatar jghaines avatar rwmartinez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatgpt-voice-assistant's Issues

Refactor unit tests

Overview

After refactoring all of the classes to follow design principles the unit tests are broken.

Acceptance Criteria

  • Refactor all unit tests to get 100% coverage and make sure they all pass

Add OpenAI Whisper option

Overview

Add an option to choose OpenAI Whisper for speech to text instead of Google's free API.

Acceptance Criteria

  • A CLI option is added to select which speech to text API is used, Google or OpenAI Whisper
  • Add unit tests to cover new functionality

Add the option to set a wake word for commands / requests

Overview

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.

Acceptance Criteria

  • Add the option to pass a wake word as a CLI parameter when running the application (similar to safe word)
  • Add the appropriate unit tests to cover the changes

Update OpenAI client to use ChatCompletion instead of Completion

Overview

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.

Acceptance Criteria

  • Use ChatCompletion instead of Completion
  • Save the send the chat history with each request
  • Add unit tests to cover all new functionality

Add test coverage

Overview

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

Why make this change?

We should increase the level of test coverage to ensure there are no regressions when adding or changing code.

Acceptance Criteria to Meet

  • Test coverage is >= 85%
  • All tests pass the workflow
  • Unit tests only test the public interfaces and not implementation details

Error: This chat model is not supported on v1

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.