Spaces:
Running
Running
jhj0517
commited on
Commit
·
2240740
1
Parent(s):
4e9280e
Add constants and apply
Browse files- app.py +1 -1
- modules/translation/deepl_api.py +2 -1
- modules/utils/constants.py +3 -0
- modules/whisper/whisper_base.py +2 -1
- modules/whisper/whisper_parameter.py +3 -1
app.py
CHANGED
@@ -53,7 +53,7 @@ class App:
|
|
53 |
with gr.Row():
|
54 |
dd_model = gr.Dropdown(choices=self.whisper_inf.available_models, value=whisper_params["model_size"],
|
55 |
label="Model")
|
56 |
-
dd_lang = gr.Dropdown(choices=[
|
57 |
value=whisper_params["lang"], label="Language")
|
58 |
dd_file_format = gr.Dropdown(choices=["SRT", "WebVTT", "txt"], value="SRT", label="File Format")
|
59 |
with gr.Row():
|
|
|
53 |
with gr.Row():
|
54 |
dd_model = gr.Dropdown(choices=self.whisper_inf.available_models, value=whisper_params["model_size"],
|
55 |
label="Model")
|
56 |
+
dd_lang = gr.Dropdown(choices=[AUTOMATIC_DETECTION] + self.whisper_inf.available_langs,
|
57 |
value=whisper_params["lang"], label="Language")
|
58 |
dd_file_format = gr.Dropdown(choices=["SRT", "WebVTT", "txt"], value="SRT", label="File Format")
|
59 |
with gr.Row():
|
modules/translation/deepl_api.py
CHANGED
@@ -5,6 +5,7 @@ from datetime import datetime
|
|
5 |
import gradio as gr
|
6 |
|
7 |
from modules.utils.paths import TRANSLATION_OUTPUT_DIR, DEFAULT_PARAMETERS_CONFIG_PATH
|
|
|
8 |
from modules.utils.subtitle_manager import *
|
9 |
from modules.utils.files_manager import load_yaml, save_yaml
|
10 |
|
@@ -50,7 +51,7 @@ DEEPL_AVAILABLE_TARGET_LANGS = {
|
|
50 |
}
|
51 |
|
52 |
DEEPL_AVAILABLE_SOURCE_LANGS = {
|
53 |
-
|
54 |
'Bulgarian': 'BG',
|
55 |
'Czech': 'CS',
|
56 |
'Danish': 'DA',
|
|
|
5 |
import gradio as gr
|
6 |
|
7 |
from modules.utils.paths import TRANSLATION_OUTPUT_DIR, DEFAULT_PARAMETERS_CONFIG_PATH
|
8 |
+
from modules.utils.constants import AUTOMATIC_DETECTION
|
9 |
from modules.utils.subtitle_manager import *
|
10 |
from modules.utils.files_manager import load_yaml, save_yaml
|
11 |
|
|
|
51 |
}
|
52 |
|
53 |
DEEPL_AVAILABLE_SOURCE_LANGS = {
|
54 |
+
AUTOMATIC_DETECTION: None,
|
55 |
'Bulgarian': 'BG',
|
56 |
'Czech': 'CS',
|
57 |
'Danish': 'DA',
|
modules/utils/constants.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from gradio_i18n import Translate, gettext as _
|
2 |
+
|
3 |
+
AUTOMATIC_DETECTION = _("Automatic Detection")
|
modules/whisper/whisper_base.py
CHANGED
@@ -14,6 +14,7 @@ from dataclasses import astuple
|
|
14 |
from modules.uvr.music_separator import MusicSeparator
|
15 |
from modules.utils.paths import (WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR, DEFAULT_PARAMETERS_CONFIG_PATH,
|
16 |
UVR_MODELS_DIR)
|
|
|
17 |
from modules.utils.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
|
18 |
from modules.utils.youtube_manager import get_ytdata, get_ytaudio
|
19 |
from modules.utils.files_manager import get_media_files, format_gradio_files, load_yaml, save_yaml
|
@@ -107,7 +108,7 @@ class WhisperBase(ABC):
|
|
107 |
|
108 |
if params.lang is None:
|
109 |
pass
|
110 |
-
elif params.lang ==
|
111 |
params.lang = None
|
112 |
else:
|
113 |
language_code_dict = {value: key for key, value in whisper.tokenizer.LANGUAGES.items()}
|
|
|
14 |
from modules.uvr.music_separator import MusicSeparator
|
15 |
from modules.utils.paths import (WHISPER_MODELS_DIR, DIARIZATION_MODELS_DIR, OUTPUT_DIR, DEFAULT_PARAMETERS_CONFIG_PATH,
|
16 |
UVR_MODELS_DIR)
|
17 |
+
from modules.utils.constants import AUTOMATIC_DETECTION
|
18 |
from modules.utils.subtitle_manager import get_srt, get_vtt, get_txt, write_file, safe_filename
|
19 |
from modules.utils.youtube_manager import get_ytdata, get_ytaudio
|
20 |
from modules.utils.files_manager import get_media_files, format_gradio_files, load_yaml, save_yaml
|
|
|
108 |
|
109 |
if params.lang is None:
|
110 |
pass
|
111 |
+
elif params.lang == AUTOMATIC_DETECTION:
|
112 |
params.lang = None
|
113 |
else:
|
114 |
language_code_dict = {value: key for key, value in whisper.tokenizer.LANGUAGES.items()}
|
modules/whisper/whisper_parameter.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
from typing import Optional, Dict
|
4 |
import yaml
|
5 |
|
|
|
|
|
6 |
|
7 |
@dataclass
|
8 |
class WhisperParameters:
|
@@ -306,7 +308,7 @@ class WhisperValues:
|
|
306 |
data = {
|
307 |
"whisper": {
|
308 |
"model_size": self.model_size,
|
309 |
-
"lang":
|
310 |
"is_translate": self.is_translate,
|
311 |
"beam_size": self.beam_size,
|
312 |
"log_prob_threshold": self.log_prob_threshold,
|
|
|
3 |
from typing import Optional, Dict
|
4 |
import yaml
|
5 |
|
6 |
+
from modules.utils.constants import AUTOMATIC_DETECTION
|
7 |
+
|
8 |
|
9 |
@dataclass
|
10 |
class WhisperParameters:
|
|
|
308 |
data = {
|
309 |
"whisper": {
|
310 |
"model_size": self.model_size,
|
311 |
+
"lang": AUTOMATIC_DETECTION if self.lang is None else self.lang,
|
312 |
"is_translate": self.is_translate,
|
313 |
"beam_size": self.beam_size,
|
314 |
"log_prob_threshold": self.log_prob_threshold,
|