Spaces:
Running
Running
jhj0517
commited on
Commit
Β·
ada247c
1
Parent(s):
201b316
refactored directory structure
Browse files- app.py +7 -8
- modules/diarize/__init__.py +0 -0
- modules/{diarize_pipeline.py β diarize/diarize_pipeline.py} +0 -0
- modules/{diarizer.py β diarize/diarizer.py} +4 -5
- modules/translation/__init__.py +0 -0
- modules/{deepl_api.py β translation/deepl_api.py} +3 -3
- modules/{nllb_inference.py β translation/nllb_inference.py} +1 -1
- modules/{translation_base.py β translation/translation_base.py} +6 -6
- modules/utils/__init__.py +0 -0
- modules/{subtitle_manager.py β utils/subtitle_manager.py} +0 -0
- modules/{youtube_manager.py β utils/youtube_manager.py} +0 -0
- modules/whisper/__init__.py +0 -0
- modules/{faster_whisper_inference.py β whisper/faster_whisper_inference.py} +2 -2
- modules/{insanely_fast_whisper_inference.py β whisper/insanely_fast_whisper_inference.py} +2 -2
- modules/{whisper_Inference.py β whisper/whisper_Inference.py} +2 -3
- modules/{whisper_base.py β whisper/whisper_base.py} +4 -6
- modules/{whisper_parameter.py β whisper/whisper_parameter.py} +0 -0
app.py
CHANGED
|
@@ -1,15 +1,14 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
import os
|
| 3 |
import argparse
|
| 4 |
|
| 5 |
-
from modules.whisper_Inference import WhisperInference
|
| 6 |
-
from modules.faster_whisper_inference import FasterWhisperInference
|
| 7 |
-
from modules.insanely_fast_whisper_inference import InsanelyFastWhisperInference
|
| 8 |
-
from modules.nllb_inference import NLLBInference
|
| 9 |
from ui.htmls import *
|
| 10 |
-
from modules.youtube_manager import get_ytmetas
|
| 11 |
-
from modules.deepl_api import DeepLAPI
|
| 12 |
-
from modules.whisper_parameter import *
|
| 13 |
|
| 14 |
|
| 15 |
class App:
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import argparse
|
| 3 |
|
| 4 |
+
from modules.whisper.whisper_Inference import WhisperInference
|
| 5 |
+
from modules.whisper.faster_whisper_inference import FasterWhisperInference
|
| 6 |
+
from modules.whisper.insanely_fast_whisper_inference import InsanelyFastWhisperInference
|
| 7 |
+
from modules.translation.nllb_inference import NLLBInference
|
| 8 |
from ui.htmls import *
|
| 9 |
+
from modules.utils.youtube_manager import get_ytmetas
|
| 10 |
+
from modules.translation.deepl_api import DeepLAPI
|
| 11 |
+
from modules.whisper.whisper_parameter import *
|
| 12 |
|
| 13 |
|
| 14 |
class App:
|
modules/diarize/__init__.py
ADDED
|
File without changes
|
modules/{diarize_pipeline.py β diarize/diarize_pipeline.py}
RENAMED
|
File without changes
|
modules/{diarizer.py β diarize/diarizer.py}
RENAMED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
import os
|
| 2 |
-
import whisperx
|
| 3 |
import torch
|
| 4 |
from typing import List
|
| 5 |
import time
|
| 6 |
|
| 7 |
-
from modules.diarize_pipeline import DiarizationPipeline
|
| 8 |
-
|
| 9 |
|
| 10 |
class Diarizer:
|
| 11 |
def __init__(self,
|
|
@@ -55,9 +54,9 @@ class Diarizer:
|
|
| 55 |
use_auth_token=use_auth_token
|
| 56 |
)
|
| 57 |
|
| 58 |
-
audio =
|
| 59 |
diarization_segments = self.pipe(audio)
|
| 60 |
-
diarized_result =
|
| 61 |
diarization_segments,
|
| 62 |
{"segments": transcribed_result}
|
| 63 |
)
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
import torch
|
| 3 |
from typing import List
|
| 4 |
import time
|
| 5 |
|
| 6 |
+
from modules.diarize.diarize_pipeline import DiarizationPipeline, assign_word_speakers
|
| 7 |
+
from modules.diarize.audio_loader import load_audio
|
| 8 |
|
| 9 |
class Diarizer:
|
| 10 |
def __init__(self,
|
|
|
|
| 54 |
use_auth_token=use_auth_token
|
| 55 |
)
|
| 56 |
|
| 57 |
+
audio = load_audio(audio)
|
| 58 |
diarization_segments = self.pipe(audio)
|
| 59 |
+
diarized_result = assign_word_speakers(
|
| 60 |
diarization_segments,
|
| 61 |
{"segments": transcribed_result}
|
| 62 |
)
|
modules/translation/__init__.py
ADDED
|
File without changes
|
modules/{deepl_api.py β translation/deepl_api.py}
RENAMED
|
@@ -4,7 +4,7 @@ import os
|
|
| 4 |
from datetime import datetime
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
-
from modules.subtitle_manager import *
|
| 8 |
|
| 9 |
"""
|
| 10 |
This is written with reference to the DeepL API documentation.
|
|
@@ -144,7 +144,7 @@ class DeepLAPI:
|
|
| 144 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 145 |
|
| 146 |
file_name = file_name[:-9]
|
| 147 |
-
output_path = os.path.join(self.output_dir, "
|
| 148 |
write_file(subtitle, output_path)
|
| 149 |
|
| 150 |
elif file_ext == ".vtt":
|
|
@@ -164,7 +164,7 @@ class DeepLAPI:
|
|
| 164 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 165 |
|
| 166 |
file_name = file_name[:-9]
|
| 167 |
-
output_path = os.path.join(self.output_dir, "
|
| 168 |
|
| 169 |
write_file(subtitle, output_path)
|
| 170 |
|
|
|
|
| 4 |
from datetime import datetime
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
from modules.utils.subtitle_manager import *
|
| 8 |
|
| 9 |
"""
|
| 10 |
This is written with reference to the DeepL API documentation.
|
|
|
|
| 144 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 145 |
|
| 146 |
file_name = file_name[:-9]
|
| 147 |
+
output_path = os.path.join(self.output_dir, "", f"{file_name}-{timestamp}.srt")
|
| 148 |
write_file(subtitle, output_path)
|
| 149 |
|
| 150 |
elif file_ext == ".vtt":
|
|
|
|
| 164 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 165 |
|
| 166 |
file_name = file_name[:-9]
|
| 167 |
+
output_path = os.path.join(self.output_dir, "", f"{file_name}-{timestamp}.vtt")
|
| 168 |
|
| 169 |
write_file(subtitle, output_path)
|
| 170 |
|
modules/{nllb_inference.py β translation/nllb_inference.py}
RENAMED
|
@@ -2,7 +2,7 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
|
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
from modules.translation_base import TranslationBase
|
| 6 |
|
| 7 |
|
| 8 |
class NLLBInference(TranslationBase):
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
|
| 5 |
+
from modules.translation.translation_base import TranslationBase
|
| 6 |
|
| 7 |
|
| 8 |
class NLLBInference(TranslationBase):
|
modules/{translation_base.py β translation/translation_base.py}
RENAMED
|
@@ -5,8 +5,8 @@ from abc import ABC, abstractmethod
|
|
| 5 |
from typing import List
|
| 6 |
from datetime import datetime
|
| 7 |
|
| 8 |
-
from modules.whisper_parameter import *
|
| 9 |
-
from modules.subtitle_manager import *
|
| 10 |
|
| 11 |
|
| 12 |
class TranslationBase(ABC):
|
|
@@ -90,9 +90,9 @@ class TranslationBase(ABC):
|
|
| 90 |
|
| 91 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 92 |
if add_timestamp:
|
| 93 |
-
output_path = os.path.join("outputs", "
|
| 94 |
else:
|
| 95 |
-
output_path = os.path.join("outputs", "
|
| 96 |
|
| 97 |
elif file_ext == ".vtt":
|
| 98 |
parsed_dicts = parse_vtt(file_path=file_path)
|
|
@@ -105,9 +105,9 @@ class TranslationBase(ABC):
|
|
| 105 |
|
| 106 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 107 |
if add_timestamp:
|
| 108 |
-
output_path = os.path.join(self.output_dir, "
|
| 109 |
else:
|
| 110 |
-
output_path = os.path.join(self.output_dir, "
|
| 111 |
|
| 112 |
write_file(subtitle, output_path)
|
| 113 |
files_info[file_name] = subtitle
|
|
|
|
| 5 |
from typing import List
|
| 6 |
from datetime import datetime
|
| 7 |
|
| 8 |
+
from modules.whisper.whisper_parameter import *
|
| 9 |
+
from modules.utils.subtitle_manager import *
|
| 10 |
|
| 11 |
|
| 12 |
class TranslationBase(ABC):
|
|
|
|
| 90 |
|
| 91 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 92 |
if add_timestamp:
|
| 93 |
+
output_path = os.path.join("outputs", "", f"{file_name}-{timestamp}.srt")
|
| 94 |
else:
|
| 95 |
+
output_path = os.path.join("outputs", "", f"{file_name}.srt")
|
| 96 |
|
| 97 |
elif file_ext == ".vtt":
|
| 98 |
parsed_dicts = parse_vtt(file_path=file_path)
|
|
|
|
| 105 |
|
| 106 |
timestamp = datetime.now().strftime("%m%d%H%M%S")
|
| 107 |
if add_timestamp:
|
| 108 |
+
output_path = os.path.join(self.output_dir, "", f"{file_name}-{timestamp}.vtt")
|
| 109 |
else:
|
| 110 |
+
output_path = os.path.join(self.output_dir, "", f"{file_name}.vtt")
|
| 111 |
|
| 112 |
write_file(subtitle, output_path)
|
| 113 |
files_info[file_name] = subtitle
|
modules/utils/__init__.py
ADDED
|
File without changes
|
modules/{subtitle_manager.py β utils/subtitle_manager.py}
RENAMED
|
File without changes
|
modules/{youtube_manager.py β utils/youtube_manager.py}
RENAMED
|
File without changes
|
modules/whisper/__init__.py
ADDED
|
File without changes
|
modules/{faster_whisper_inference.py β whisper/faster_whisper_inference.py}
RENAMED
|
@@ -9,8 +9,8 @@ import whisper
|
|
| 9 |
import gradio as gr
|
| 10 |
from argparse import Namespace
|
| 11 |
|
| 12 |
-
from modules.whisper_parameter import *
|
| 13 |
-
from modules.whisper_base import WhisperBase
|
| 14 |
|
| 15 |
|
| 16 |
class FasterWhisperInference(WhisperBase):
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
from argparse import Namespace
|
| 11 |
|
| 12 |
+
from modules.whisper.whisper_parameter import *
|
| 13 |
+
from modules.whisper.whisper_base import WhisperBase
|
| 14 |
|
| 15 |
|
| 16 |
class FasterWhisperInference(WhisperBase):
|
modules/{insanely_fast_whisper_inference.py β whisper/insanely_fast_whisper_inference.py}
RENAMED
|
@@ -11,8 +11,8 @@ import whisper
|
|
| 11 |
from rich.progress import Progress, TimeElapsedColumn, BarColumn, TextColumn
|
| 12 |
from argparse import Namespace
|
| 13 |
|
| 14 |
-
from modules.whisper_parameter import *
|
| 15 |
-
from modules.whisper_base import WhisperBase
|
| 16 |
|
| 17 |
|
| 18 |
class InsanelyFastWhisperInference(WhisperBase):
|
|
|
|
| 11 |
from rich.progress import Progress, TimeElapsedColumn, BarColumn, TextColumn
|
| 12 |
from argparse import Namespace
|
| 13 |
|
| 14 |
+
from modules.whisper.whisper_parameter import *
|
| 15 |
+
from modules.whisper.whisper_base import WhisperBase
|
| 16 |
|
| 17 |
|
| 18 |
class InsanelyFastWhisperInference(WhisperBase):
|
modules/{whisper_Inference.py β whisper/whisper_Inference.py}
RENAMED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
import whisper
|
| 2 |
import gradio as gr
|
| 3 |
import time
|
| 4 |
-
import os
|
| 5 |
from typing import BinaryIO, Union, Tuple, List
|
| 6 |
import numpy as np
|
| 7 |
import torch
|
| 8 |
from argparse import Namespace
|
| 9 |
|
| 10 |
-
from modules.whisper_base import WhisperBase
|
| 11 |
-
from modules.whisper_parameter import *
|
| 12 |
|
| 13 |
|
| 14 |
class WhisperInference(WhisperBase):
|
|
|
|
| 1 |
import whisper
|
| 2 |
import gradio as gr
|
| 3 |
import time
|
|
|
|
| 4 |
from typing import BinaryIO, Union, Tuple, List
|
| 5 |
import numpy as np
|
| 6 |
import torch
|
| 7 |
from argparse import Namespace
|
| 8 |
|
| 9 |
+
from modules.whisper.whisper_base import WhisperBase
|
| 10 |
+
from modules.whisper.whisper_parameter import *
|
| 11 |
|
| 12 |
|
| 13 |
class WhisperInference(WhisperBase):
|
modules/{whisper_base.py β whisper/whisper_base.py}
RENAMED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
import torch
|
| 3 |
-
from typing import List
|
| 4 |
import whisper
|
| 5 |
import gradio as gr
|
| 6 |
from abc import ABC, abstractmethod
|
|
@@ -8,12 +7,11 @@ from typing import BinaryIO, Union, Tuple, List
|
|
| 8 |
import numpy as np
|
| 9 |
from datetime import datetime
|
| 10 |
from argparse import Namespace
|
| 11 |
-
import time
|
| 12 |
|
| 13 |
-
from modules.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
|
| 14 |
-
from modules.youtube_manager import get_ytdata, get_ytaudio
|
| 15 |
-
from modules.whisper_parameter import *
|
| 16 |
-
from modules.diarizer import Diarizer
|
| 17 |
|
| 18 |
|
| 19 |
class WhisperBase(ABC):
|
|
|
|
| 1 |
import os
|
| 2 |
import torch
|
|
|
|
| 3 |
import whisper
|
| 4 |
import gradio as gr
|
| 5 |
from abc import ABC, abstractmethod
|
|
|
|
| 7 |
import numpy as np
|
| 8 |
from datetime import datetime
|
| 9 |
from argparse import Namespace
|
|
|
|
| 10 |
|
| 11 |
+
from modules.utils.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
|
| 12 |
+
from modules.utils.youtube_manager import get_ytdata, get_ytaudio
|
| 13 |
+
from modules.whisper.whisper_parameter import *
|
| 14 |
+
from modules.diarize.diarizer import Diarizer
|
| 15 |
|
| 16 |
|
| 17 |
class WhisperBase(ABC):
|
modules/{whisper_parameter.py β whisper/whisper_parameter.py}
RENAMED
|
File without changes
|