From 5942057698cc283c17de65bdbe2ee1ea6867f57d Mon Sep 17 00:00:00 2001
From: 游雁 <zhifu.gzf@alibaba-inc.com>
Date: 星期一, 25 三月 2024 11:15:24 +0800
Subject: [PATCH] install requirements automatically

---
 funasr/download/download_from_hub.py |    2 ++
 funasr/frontends/whisper_frontend.py |    7 ++++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/funasr/download/download_from_hub.py b/funasr/download/download_from_hub.py
index f23be0d..46704b0 100644
--- a/funasr/download/download_from_hub.py
+++ b/funasr/download/download_from_hub.py
@@ -73,6 +73,8 @@
     if isinstance(kwargs, DictConfig):
         kwargs = OmegaConf.to_container(kwargs, resolve=True)
     if os.path.exists(os.path.join(model_or_path, "requirements.txt")):
+        requirements = os.path.join(model_or_path, "requirements.txt")
+        print(f"Detect model requirements, begin to install it: {requirements}")
         from funasr.utils.install_model_requirements import install_requirements
         install_requirements(os.path.join(model_or_path, "requirements.txt"))
     return kwargs
diff --git a/funasr/frontends/whisper_frontend.py b/funasr/frontends/whisper_frontend.py
index 0598c61..dd61f8e 100644
--- a/funasr/frontends/whisper_frontend.py
+++ b/funasr/frontends/whisper_frontend.py
@@ -1,8 +1,8 @@
 from typing import Tuple
 import torch
 import torch.nn as nn
-import whisper
-from whisper.audio import HOP_LENGTH, N_FFT, N_SAMPLES
+
+
 from funasr.register import tables
 from torch.nn.utils.rnn import pad_sequence
 
@@ -26,7 +26,8 @@
         super().__init__()
         assert fs == 16000
         self.fs = fs
-
+        import whisper
+        from whisper.audio import HOP_LENGTH, N_FFT, N_SAMPLES
         self.n_fft = N_FFT
         self.win_length = N_FFT
         self.hop_length = HOP_LENGTH

--
Gitblit v1.9.1