-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from Huanshere/dev_v8_longvideo
Dev v8 longvideo
- Loading branch information
Showing
23 changed files
with
326 additions
and
446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
import os,sys | ||
import spacy | ||
from spacy.cli import download | ||
from rich import print | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | ||
from core.step2_whisper import get_whisper_language | ||
from config import SPACY_MODEL_MAP | ||
|
||
def get_spacy_model(language: str): | ||
model = SPACY_MODEL_MAP.get(language.lower(), "en_core_web_sm") | ||
if language not in SPACY_MODEL_MAP: | ||
print(f"Spacy model does not support '{language}', using en_core_web_sm model as fallback...") | ||
print(f"[yellow]Spacy model does not support '{language}', using en_core_web_sm model as fallback...[/yellow]") | ||
return model | ||
|
||
def init_nlp(): | ||
try: | ||
from config import WHISPER_LANGUAGE | ||
language = "en" if WHISPER_LANGUAGE == "en" else get_whisper_language() | ||
model = get_spacy_model(language) | ||
print(f"⏳ Loading NLP Spacy model: <{model}> ...") | ||
print(f"[blue]⏳ Loading NLP Spacy model: <{model}> ...[/blue]") | ||
try: | ||
nlp = spacy.load(model) | ||
except: | ||
print(f"Downloading {model} model...") | ||
print("If download failed, please check your network and try again.") | ||
print(f"[yellow]Downloading {model} model...[/yellow]") | ||
print("[yellow]If download failed, please check your network and try again.[/yellow]") | ||
download(model) | ||
nlp = spacy.load(model) | ||
except: | ||
raise ValueError(f"❌ Failed to load NLP Spacy model: {model}") | ||
print(f"✅ NLP Spacy model loaded successfully!") | ||
print(f"[green]✅ NLP Spacy model loaded successfully![/green]") | ||
return nlp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.