SevaSk / 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.
https://github.com/SevaSk/ecoute
MIT License
5.89k stars 827 forks source link

feat(code quality): add black and ruff #56

Open zarifpour opened 1 year ago

zarifpour commented 1 year ago

I added black and ruff to maintain code quality and implemented a Makefile streamline the execution of common commands.

I also tried to add poetry as the dependency manager, but it was not compatible with the dependency openai-whisper. It seemed to consistently fail on the installation of tritton.

For reference, this is as far as I was able to get:

# pyproject.toml

[tool.poetry]
name = "ecoute"
version = "0.1.0"
description = "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."
authors = ["Seva <seva.sk@gmail.com>"]
license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8"
numpy = "==1.24.3"
openai-whisper = "==20230314"
Wave = "==0.0.2"
openai = "==0.27.6"
customtkinter = "==5.1.3"
torch = "==2.0.0"

[tool.poetry.dependencies.PyAudioWPatch]
version = "==0.2.12.5"
platform = "win32"

[tool.poetry.dependencies.pyaudio]
version = "*"
platform = "darwin"

# poetry replacement for: `--extra-index-url https://download.pytorch.org/whl/cu117`
[[tool.poetry.source]]
name = "torch"
url = "https://download.pytorch.org/whl/cu117"
priority = "supplemental"

[[tool.poetry.source]]
name = "PyPI"
priority = "primary"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

It fails with this error (there was another one for tritton, but I seemed to have lost it somewhere in my console):

Package operations: 6 installs, 1 update, 0 removals

   • Updating torch (2.0.1 -> 2.0.0+cu117): Failed

   RuntimeError

   Unable to find installation candidates for torch (2.0.0+cu117)

   at ~/.pyenv/versions/3.11.1/lib/python3.11/site-packages/poetry/installation/chooser.py:76 in choose_for
        72│ 
        73│             links.append(link)
        74│ 
        75│         if not links:
   →  76│             raise RuntimeError(f"Unable to find installation candidates for {package}")
        77│ 
        78│         # Get the best link
        79│         chosen = max(links, key=lambda link: self._sort_key(package, link))
        80│ 

I noticed another developer had a similar issue: https://github.com/orgs/python-poetry/discussions/7199

SevaSk commented 1 year ago

Thanks for contributing! Could you split the PR between the streamlined installation changes and black and ruff changes? Want to consider those changes separately. Also I think we should ignore linting custom_speech_recognition since its just a copy of the existing SpeechRecognition library with some modifications. Probably a better way to maintain that I haven't considered how.

zarifpour commented 1 year ago

Thanks for contributing! Could you split the PR between the streamlined installation changes and black and ruff changes? Want to consider those changes separately. Also I think we should ignore linting custom_speech_recognition since its just a copy of the existing SpeechRecognition library with some modifications. Probably a better way to maintain that I haven't considered how.

I see, I didn't realize it was a copy of an existing SpeechRecognition library. In that case, I will ignore it in regards to linting and formatting. Would it make sense to do something like this - where the library is its own git repo?

Example from: https://github.com/foundry-rs/foundry-rust-template/tree/master/contracts/lib

CleanShot_2023-06-01_16 58 02_Arc_000862@2x
SevaSk commented 1 year ago

Not sure why but make lint and make format cant find python files image

image

zarifpour commented 1 year ago

Not sure why but make lint and make format cant find python files

image

image

Hmm, I'm not sure. Maybe the way black behaves is different on windows. Can you try modifying a python file to contain single quotes for a string, instead of double quotes, and see if you get the same message. Perhaps it's behaving normally?

zarifpour commented 1 year ago

I think this is good to go. If you get a chance to review + merge, I would appreciate it. Thanks!