Skip to content

Commit

Permalink
Try using non-transformer spacy model
Browse files Browse the repository at this point in the history
  • Loading branch information
evamaxfield committed Dec 5, 2023
1 parent 06f618a commit 623871b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cdp_backend/sr_models/whisper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import TYPE_CHECKING, Any

import spacy
import spacy_transformers # noqa: F401
from faster_whisper import WhisperModel as FasterWhisper
from pydub import AudioSegment
from spacy.cli.download import download as download_spacy_model
Expand All @@ -30,6 +29,7 @@

###############################################################################

DEFAULT_SPACY_MODEL = "en_core_web_lg"
spacy.prefer_gpu()

###############################################################################
Expand All @@ -48,7 +48,7 @@ class WhisperModel(SRModel):
@staticmethod
def _load_spacy_model() -> "Language":
nlp = spacy.load(
"en_core_web_trf",
DEFAULT_SPACY_MODEL,
# Only keep the parser
# We are only using this for sentence parsing
disable=[
Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(
try:
self.nlp = self._load_spacy_model()
except Exception:
download_spacy_model("en_core_web_trf")
download_spacy_model(DEFAULT_SPACY_MODEL)
self.nlp = self._load_spacy_model()

def transcribe(
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ Documentation = "https://CouncilDataProject.github.io/cdp-backend"
# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
[project.optional-dependencies]
pipeline = [
"curated-transformers>=0.1.1",
"dask[distributed]>=2021.7.0",
"faster-whisper==0.3.0",
"ffmpeg-python>=0.2.0",
Expand All @@ -74,7 +73,6 @@ pipeline = [
"pypdf>=2.0",
"rapidfuzz>=2.0",
"spacy>=3.4",
"spacy-transformers>=1.1",
"tika==2.6.0",
"torch>=1.10,<2",
"tqdm>=4.62",
Expand Down

0 comments on commit 623871b

Please sign in to comment.