From 0315d8e67f9d1abe256de6b0ac155a2e7caaa950 Mon Sep 17 00:00:00 2001 From: martin legrand Date: Thu, 13 Mar 2025 14:48:02 +0100 Subject: [PATCH] Fix : setup.py for browser requirement --- requirements.txt | 6 ++++++ setup.py | 9 +++++++-- sources/browser.py | 4 ++-- sources/speech_to_text.py | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index d8fa3ac..f7182a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,6 +19,12 @@ pyaudio==0.2.14 librosa==0.10.2.post1 selenium==4.29.0 markdownify==1.1.0 +httpx>=0.27,<0.29 +anyio>=3.5.0,<5 +distro>=1.7.0,<2 +jiter>=0.4.0,<1 +sniffio +tqdm>4 # if use chinese ordered_set pypinyin diff --git a/setup.py b/setup.py index 856783a..335368c 100644 --- a/setup.py +++ b/setup.py @@ -31,10 +31,15 @@ setup( "termcolor==2.5.0", "gliclass==0.1.8", "ipython==8.34.0", - "pyaudio==0.2.14", "librosa==0.10.2.post1", "selenium==4.29.0", - "markdownify==1.1.0" + "markdownify==1.1.0", + "httpx>=0.27,<0.29" + "anyio>=3.5.0,<5" + "distro>=1.7.0,<2" + "jiter>=0.4.0,<1" + "sniffio" + "tqdm>4" ], extras_require={ "chinese": [ diff --git a/sources/browser.py b/sources/browser.py index 8d62eb3..279c68a 100644 --- a/sources/browser.py +++ b/sources/browser.py @@ -9,6 +9,7 @@ import time from bs4 import BeautifulSoup import markdownify import logging +import sys class Browser: def __init__(self, headless=False): @@ -24,7 +25,6 @@ class Browser: self.wait = WebDriverWait(self.driver, 10) self.logger = logging.getLogger(__name__) self.logger.info("Browser initialized successfully") - except Exception as e: raise Exception(f"Failed to initialize browser: {str(e)}") @@ -136,7 +136,7 @@ class Browser: self.driver.quit() self.logger.info("Browser closed") except Exception as e: - self.logger.error(f"Error closing browser: {str(e)}") + raise e def __del__(self): """Destructor to ensure browser is closed.""" diff --git a/sources/speech_to_text.py b/sources/speech_to_text.py index 47416f2..776dce3 100644 --- a/sources/speech_to_text.py +++ b/sources/speech_to_text.py @@ -1,5 +1,4 @@ from colorama import Fore -import pyaudio import queue import threading import numpy as np @@ -15,7 +14,8 @@ class AudioRecorder: """ AudioRecorder is a class that records audio from the microphone and adds it to the audio queue. """ - def __init__(self, format: int = pyaudio.paInt16, channels: int = 1, rate: int = 4096, chunk: int = 8192, record_seconds: int = 5, verbose: bool = False): + def __init__(self, format: int, channels: int = 1, rate: int = 4096, chunk: int = 8192, record_seconds: int = 5, verbose: bool = False): + import pyaudio self.format = format self.channels = channels self.rate = rate