Skip to content

Commit

Permalink
Expand OBS web socket intergration, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelseeger committed Jul 23, 2024
1 parent 7cbb23f commit 9190fb1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
33 changes: 12 additions & 21 deletions Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Notes on how to setup dependencies; In general, create a new env with conda:

```sh
conda env create --name aicoach311 --file=environments-cp311.yml
conda env create --file=environments-cp311.yml
```

Python 3.11 is the only version that works with all dependencies at this point.
Expand All @@ -19,33 +19,24 @@ import openwakeword
openwakeword.utils.download_models()
```

## Flash attention

https://pypi.org/project/flash-attn/

Set MAX_JOBS=4 if less than 100Gb of RAM

## pytorch with CUDA

Needs a CUDA capabale NVidia GPU to run fast whisper.

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

## tesseract

Install tesseract with language data. (Windows: https://github.com/UB-Mannheim/tesseract/wiki).
If installed to non-default location adjust tessdata_dir in config.

## RealtimeTTS

https://github.com/KoljaB/RealtimeTTS?tab=readme-ov-file

Install manually then reinstall openai as RealtimeTTS downgrades openai on installation.
## Flash attention

After installation, remove TTS (not maintained anymore)
https://pypi.org/project/flash-attn/

`pip uninstall TTS`
Notes:
- Get C++ build tools: https://visualstudio.microsoft.com/visual-cpp-build-tools/
- MSVC C++ 2022 build tools latest
- Windows 11 SDK
- Get ninja: ```pip install ninja```
- Set MAX_JOBS=4 if less than 100Gb of RAM

and instead install coqui-tts
## tesseract

`pip install coqui-tts`
Install tesseract with language data. (Windows: https://github.com/UB-Mannheim/tesseract/wiki).
If installed to non-default location adjust tessdata_dir in config.
2 changes: 1 addition & 1 deletion environment-cp311.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ dependencies:
- SpeechRecognition
#- flash_attn # https://pypi.org/project/flash-attn/
- pyodmongo
#- RealtimeTTS # install manually as it downgrades openai
- realtimetts[system,coqui]
- keyboard
- obsws-python
5 changes: 3 additions & 2 deletions obs_tools/sc2client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import threading
from time import sleep, time
from urllib.parse import urljoin

import requests
from blinker import signal
Expand All @@ -24,7 +25,7 @@
class SC2Client:
def get_gameinfo(self) -> GameInfo:
try:
response = requests.get(config.sc2_client_url + "/game")
response = requests.get(urljoin(config.sc2_client_url, "/game"))
if response.status_code == 200:
try:
game = GameInfo.model_validate_json(response.text)
Expand All @@ -46,7 +47,7 @@ def get_opponent_name(self, gameinfo=None) -> str:

def get_screens(self) -> UIInfo:
try:
response = requests.get(config.sc2_client_url + "/ui")
response = requests.get(urljoin(config.sc2_client_url, "/ui"))
if response.status_code == 200:
try:
ui = UIInfo.model_validate_json(response.text)
Expand Down
2 changes: 1 addition & 1 deletion obs_tools/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ def is_decided(self) -> bool:


class UIInfo(BaseModel):
activeScreens: List[Screen]
activeScreens: set[Screen]
6 changes: 3 additions & 3 deletions tests/integration/test_obs_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@


# SC2 must be running and a game must be in progress or have been played recently
# or use https://github.com/leigholiver/sc2apiemulator
# SC2 must not be running:
# docker run -d --rm -p6119:80 --name sc2api leigholiver/sc2api
# or use https://github.com/manuelseeger/sc2apiemulator
def test_sc2client_get_opponent():

client = SC2Client()
Expand All @@ -28,3 +26,5 @@ def test_sc2client_get_opponent():
print(f"Is barcode: {barcode}")

assert opponent is not None


17 changes: 17 additions & 0 deletions tests/unit/test_sc2client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from config import config
from obs_tools.sc2client import SC2Client
from obs_tools.types import GameInfo, Screen, UIInfo


def test_uiinfo_equality_loading():
ui1 = UIInfo(activeScreens=[Screen.loading])
ui2 = UIInfo(activeScreens=[Screen.loading])

assert ui1 == ui2


def test_uiinfo_equality_menus():
ui1 = UIInfo(activeScreens=[Screen.background, Screen.foreground, Screen.navigation, Screen.home ])
ui2 = UIInfo(activeScreens=[Screen.home, Screen.background, Screen.foreground, Screen.navigation])

assert ui1 == ui2

0 comments on commit 9190fb1

Please sign in to comment.