From 05cf1b1eeb51dd02e49af71e1bf92271a9fb8805 Mon Sep 17 00:00:00 2001 From: Viet-Anh Nguyen Date: Sat, 5 Oct 2024 10:28:06 +0700 Subject: [PATCH] Add missing import + Build for Linux --- LlamaAssistant.spec | 19 ++++++++++++++----- README.md | 37 +++++++++++++++++++++++++++++++++++++ build.sh | 2 +- pyproject.toml | 3 ++- requirements.txt | 1 + 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/LlamaAssistant.spec b/LlamaAssistant.spec index 63cb4c0..2a77275 100644 --- a/LlamaAssistant.spec +++ b/LlamaAssistant.spec @@ -6,13 +6,9 @@ import os, sys sys.setrecursionlimit(5000) # required on Windows -# Get the package path +# Collect llama.cpp package_path = get_package_paths('llama_cpp')[0] - -# Collect data files datas = collect_data_files('llama_cpp') - -# Append the additional .dll or .so file if os.name == 'nt': # Windows for l in ["ggml", "llama", "llava"]: dll_path = os.path.join(package_path, 'llama_cpp', 'lib', f'{l}.dll') @@ -26,6 +22,19 @@ elif os.name == 'posix': # Linux so_path = os.path.join(package_path, 'llama_cpp', 'lib', f'lib{l}.so') datas.append((so_path, 'llama_cpp/lib')) +# Collect whisper.cpp +package_path = get_package_paths('whisper_cpp_python')[0] +datas += collect_data_files('whisper_cpp_python') +if os.name == 'nt': # Windows + dll_path = os.path.join(package_path, 'whisper_cpp_python', 'whisper.dll') + datas.append((dll_path, 'whisper_cpp_python')) +elif sys.platform == 'darwin': # Mac + dylib_path = os.path.join(package_path, 'whisper_cpp_python', 'libwhisper.dylib') + datas.append((dylib_path, 'whisper_cpp_python')) +elif os.name == 'posix': # Linux + so_path = os.path.join(package_path, 'whisper_cpp_python', 'libwhisper.so') + datas.append((so_path, 'whisper_cpp_python')) + datas += [ ('llama_assistant/resources/*.onnx', 'llama_assistant/resources'), ('llama_assistant/resources/*.png', 'llama_assistant/resources'), diff --git a/README.md b/README.md index 357c6d6..5270b9e 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,43 @@ https://github.com/user-attachments/assets/af2c544b-6d46-4c44-87d8-9a051ba213db ## Installation +**Install PortAudio:** + +
+Install `PortAudio`_. This is required by the `PyAudio`_ library to stream +audio from your computer's microphone. PyAudio depends on PortAudio for cross-platform compatibility, and is installed differently depending on the +platform. + +* For Mac OS X, you can use `Homebrew`_:: + + brew install portaudio + + **Note**: if you encounter an error when running `pip install` that indicates + it can't find `portaudio.h`, try running `pip install` with the following + flags:: + + pip install --global-option='build_ext' \ + --global-option='-I/usr/local/include' \ + --global-option='-L/usr/local/lib' \ + pyaudio + +* For Debian / Ubuntu Linux:: + + apt-get install portaudio19-dev python3-all-dev + +* Windows may work without having to install PortAudio explicitly (it will get + installed with PyAudio). + +For more details, see the `PyAudio installation`_ page. + + +.. _PyAudio: https://people.csail.mit.edu/hubert/pyaudio/ +.. _PortAudio: http://www.portaudio.com/ +.. _PyAudio installation: + https://people.csail.mit.edu/hubert/pyaudio/#downloads +.. _Homebrew: http://brew.sh +
+ **Install from PyPI:** ```bash diff --git a/build.sh b/build.sh index c641caf..cf7c746 100644 --- a/build.sh +++ b/build.sh @@ -1 +1 @@ -pyinstaller --noconfirm LlamaAssistant.spec +python3 -O -m PyInstaller --noconfirm LlamaAssistant.spec diff --git a/pyproject.toml b/pyproject.toml index 6bb0dc4..2f940cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "llama-assistant" -version = "0.1.28" +version = "0.1.29" authors = [ {name = "Viet-Anh Nguyen", email = "vietanh.dev@gmail.com"}, ] @@ -33,6 +33,7 @@ dependencies = [ "SpeechRecognition", "huggingface_hub", "openwakeword", + "whisper-cpp-python", ] dynamic = [] diff --git a/requirements.txt b/requirements.txt index 4e9e4e9..64d09cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ llama-cpp-python huggingface_hub==0.25.1 openwakeword==0.6.0 pyinstaller==6.10.0 +whisper-cpp-python==0.2.0 \ No newline at end of file