jhj0517 commited on
Commit
8126fce
·
1 Parent(s): 5cb1a8c

Add `uvr_model_dir` path to whisper factory

Browse files
app.py CHANGED
@@ -26,6 +26,7 @@ class App:
26
  whisper_model_dir=self.args.whisper_model_dir,
27
  faster_whisper_model_dir=self.args.faster_whisper_model_dir,
28
  insanely_fast_whisper_model_dir=self.args.insanely_fast_whisper_model_dir,
 
29
  output_dir=self.args.output_dir,
30
  )
31
  self.nllb_inf = NLLBInference(
 
26
  whisper_model_dir=self.args.whisper_model_dir,
27
  faster_whisper_model_dir=self.args.faster_whisper_model_dir,
28
  insanely_fast_whisper_model_dir=self.args.insanely_fast_whisper_model_dir,
29
+ uvr_model_dir=self.args.uvr_model_dir,
30
  output_dir=self.args.output_dir,
31
  )
32
  self.nllb_inf = NLLBInference(
modules/whisper/faster_whisper_inference.py CHANGED
@@ -11,7 +11,7 @@ import whisper
11
  import gradio as gr
12
  from argparse import Namespace
13
 
14
- from modules.utils.paths import (FASTER_WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR)
15
  from modules.whisper.whisper_parameter import *
16
  from modules.whisper.whisper_base import WhisperBase
17
 
@@ -20,11 +20,13 @@ class FasterWhisperInference(WhisperBase):
20
  def __init__(self,
21
  model_dir: str = FASTER_WHISPER_MODELS_DIR,
22
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
 
23
  output_dir: str = OUTPUT_DIR,
24
  ):
25
  super().__init__(
26
  model_dir=model_dir,
27
  diarization_model_dir=diarization_model_dir,
 
28
  output_dir=output_dir
29
  )
30
  self.model_dir = model_dir
 
11
  import gradio as gr
12
  from argparse import Namespace
13
 
14
+ from modules.utils.paths import (FASTER_WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, UVR_MODELS_DIR, OUTPUT_DIR)
15
  from modules.whisper.whisper_parameter import *
16
  from modules.whisper.whisper_base import WhisperBase
17
 
 
20
  def __init__(self,
21
  model_dir: str = FASTER_WHISPER_MODELS_DIR,
22
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
23
+ uvr_model_dir: str = UVR_MODELS_DIR,
24
  output_dir: str = OUTPUT_DIR,
25
  ):
26
  super().__init__(
27
  model_dir=model_dir,
28
  diarization_model_dir=diarization_model_dir,
29
+ uvr_model_dir=uvr_model_dir,
30
  output_dir=output_dir
31
  )
32
  self.model_dir = model_dir
modules/whisper/insanely_fast_whisper_inference.py CHANGED
@@ -11,7 +11,7 @@ import whisper
11
  from rich.progress import Progress, TimeElapsedColumn, BarColumn, TextColumn
12
  from argparse import Namespace
13
 
14
- from modules.utils.paths import (INSANELY_FAST_WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR)
15
  from modules.whisper.whisper_parameter import *
16
  from modules.whisper.whisper_base import WhisperBase
17
 
@@ -20,12 +20,14 @@ class InsanelyFastWhisperInference(WhisperBase):
20
  def __init__(self,
21
  model_dir: str = INSANELY_FAST_WHISPER_MODELS_DIR,
22
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
 
23
  output_dir: str = OUTPUT_DIR,
24
  ):
25
  super().__init__(
26
  model_dir=model_dir,
27
  output_dir=output_dir,
28
- diarization_model_dir=diarization_model_dir
 
29
  )
30
  self.model_dir = model_dir
31
  os.makedirs(self.model_dir, exist_ok=True)
 
11
  from rich.progress import Progress, TimeElapsedColumn, BarColumn, TextColumn
12
  from argparse import Namespace
13
 
14
+ from modules.utils.paths import (INSANELY_FAST_WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, UVR_MODELS_DIR, OUTPUT_DIR)
15
  from modules.whisper.whisper_parameter import *
16
  from modules.whisper.whisper_base import WhisperBase
17
 
 
20
  def __init__(self,
21
  model_dir: str = INSANELY_FAST_WHISPER_MODELS_DIR,
22
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
23
+ uvr_model_dir: str = UVR_MODELS_DIR,
24
  output_dir: str = OUTPUT_DIR,
25
  ):
26
  super().__init__(
27
  model_dir=model_dir,
28
  output_dir=output_dir,
29
+ diarization_model_dir=diarization_model_dir,
30
+ uvr_model_dir=uvr_model_dir
31
  )
32
  self.model_dir = model_dir
33
  os.makedirs(self.model_dir, exist_ok=True)
modules/whisper/whisper_Inference.py CHANGED
@@ -7,7 +7,7 @@ import torch
7
  import os
8
  from argparse import Namespace
9
 
10
- from modules.utils.paths import (WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR)
11
  from modules.whisper.whisper_base import WhisperBase
12
  from modules.whisper.whisper_parameter import *
13
 
@@ -16,12 +16,14 @@ class WhisperInference(WhisperBase):
16
  def __init__(self,
17
  model_dir: str = WHISPER_MODELS_DIR,
18
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
 
19
  output_dir: str = OUTPUT_DIR,
20
  ):
21
  super().__init__(
22
  model_dir=model_dir,
23
  output_dir=output_dir,
24
- diarization_model_dir=diarization_model_dir
 
25
  )
26
 
27
  def transcribe(self,
 
7
  import os
8
  from argparse import Namespace
9
 
10
+ from modules.utils.paths import (WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR, UVR_MODELS_DIR)
11
  from modules.whisper.whisper_base import WhisperBase
12
  from modules.whisper.whisper_parameter import *
13
 
 
16
  def __init__(self,
17
  model_dir: str = WHISPER_MODELS_DIR,
18
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
19
+ uvr_model_dir: str = UVR_MODELS_DIR,
20
  output_dir: str = OUTPUT_DIR,
21
  ):
22
  super().__init__(
23
  model_dir=model_dir,
24
  output_dir=output_dir,
25
+ diarization_model_dir=diarization_model_dir,
26
+ uvr_model_dir=uvr_model_dir
27
  )
28
 
29
  def transcribe(self,
modules/whisper/whisper_factory.py CHANGED
@@ -2,7 +2,7 @@ from typing import Optional
2
  import os
3
 
4
  from modules.utils.paths import (FASTER_WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR,
5
- INSANELY_FAST_WHISPER_MODELS_DIR, WHISPER_MODELS_DIR)
6
  from modules.whisper.faster_whisper_inference import FasterWhisperInference
7
  from modules.whisper.whisper_Inference import WhisperInference
8
  from modules.whisper.insanely_fast_whisper_inference import InsanelyFastWhisperInference
@@ -17,6 +17,7 @@ class WhisperFactory:
17
  faster_whisper_model_dir: str = FASTER_WHISPER_MODELS_DIR,
18
  insanely_fast_whisper_model_dir: str = INSANELY_FAST_WHISPER_MODELS_DIR,
19
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
 
20
  output_dir: str = OUTPUT_DIR,
21
  ) -> "WhisperBase":
22
  """
@@ -37,6 +38,8 @@ class WhisperFactory:
37
  Directory path for the Insanely Fast Whisper model.
38
  diarization_model_dir : str
39
  Directory path for the diarization model.
 
 
40
  output_dir : str
41
  Directory path where output files will be saved.
42
 
@@ -61,23 +64,27 @@ class WhisperFactory:
61
  return FasterWhisperInference(
62
  model_dir=faster_whisper_model_dir,
63
  output_dir=output_dir,
64
- diarization_model_dir=diarization_model_dir
 
65
  )
66
  elif whisper_type in whisper_typos:
67
  return WhisperInference(
68
  model_dir=whisper_model_dir,
69
  output_dir=output_dir,
70
- diarization_model_dir=diarization_model_dir
 
71
  )
72
  elif whisper_type in insanely_fast_whisper_typos:
73
  return InsanelyFastWhisperInference(
74
  model_dir=insanely_fast_whisper_model_dir,
75
  output_dir=output_dir,
76
- diarization_model_dir=diarization_model_dir
 
77
  )
78
  else:
79
  return FasterWhisperInference(
80
  model_dir=faster_whisper_model_dir,
81
  output_dir=output_dir,
82
- diarization_model_dir=diarization_model_dir
 
83
  )
 
2
  import os
3
 
4
  from modules.utils.paths import (FASTER_WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR,
5
+ INSANELY_FAST_WHISPER_MODELS_DIR, WHISPER_MODELS_DIR, UVR_MODELS_DIR)
6
  from modules.whisper.faster_whisper_inference import FasterWhisperInference
7
  from modules.whisper.whisper_Inference import WhisperInference
8
  from modules.whisper.insanely_fast_whisper_inference import InsanelyFastWhisperInference
 
17
  faster_whisper_model_dir: str = FASTER_WHISPER_MODELS_DIR,
18
  insanely_fast_whisper_model_dir: str = INSANELY_FAST_WHISPER_MODELS_DIR,
19
  diarization_model_dir: str = DIARIZATION_MODELS_DIR,
20
+ uvr_model_dir: str = UVR_MODELS_DIR,
21
  output_dir: str = OUTPUT_DIR,
22
  ) -> "WhisperBase":
23
  """
 
38
  Directory path for the Insanely Fast Whisper model.
39
  diarization_model_dir : str
40
  Directory path for the diarization model.
41
+ uvr_model_dir : str
42
+ Directory path for the UVR model.
43
  output_dir : str
44
  Directory path where output files will be saved.
45
 
 
64
  return FasterWhisperInference(
65
  model_dir=faster_whisper_model_dir,
66
  output_dir=output_dir,
67
+ diarization_model_dir=diarization_model_dir,
68
+ uvr_model_dir=uvr_model_dir
69
  )
70
  elif whisper_type in whisper_typos:
71
  return WhisperInference(
72
  model_dir=whisper_model_dir,
73
  output_dir=output_dir,
74
+ diarization_model_dir=diarization_model_dir,
75
+ uvr_model_dir=uvr_model_dir
76
  )
77
  elif whisper_type in insanely_fast_whisper_typos:
78
  return InsanelyFastWhisperInference(
79
  model_dir=insanely_fast_whisper_model_dir,
80
  output_dir=output_dir,
81
+ diarization_model_dir=diarization_model_dir,
82
+ uvr_model_dir=uvr_model_dir
83
  )
84
  else:
85
  return FasterWhisperInference(
86
  model_dir=faster_whisper_model_dir,
87
  output_dir=output_dir,
88
+ diarization_model_dir=diarization_model_dir,
89
+ uvr_model_dir=uvr_model_dir
90
  )