Spaces:
Runtime error
Runtime error
add lang selection
Browse files
app.py
CHANGED
@@ -16,6 +16,34 @@ description = "Cross Language Speech to Speech (Indonesian/English to 25 other l
|
|
16 |
info = "This application uses [Indonesian Whisperer Medium](https://huggingface.co/cahya/whisper-medium-id) model"
|
17 |
badge = "https://img.shields.io/badge/Powered%20by-Indonesian%20Whisperer-red"
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
device = 0 if torch.cuda.is_available() else "cpu"
|
20 |
|
21 |
pipe = pipeline(
|
@@ -27,6 +55,7 @@ pipe = pipeline(
|
|
27 |
|
28 |
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
29 |
|
|
|
30 |
def transcribe(microphone, file_upload):
|
31 |
warn_output = ""
|
32 |
if (microphone is not None) and (file_upload is not None):
|
@@ -78,6 +107,8 @@ with gr.Blocks() as blocks:
|
|
78 |
choices=LANGUAGES,
|
79 |
value=default_lang
|
80 |
)
|
|
|
|
|
81 |
with gr.Row(): # mobile_collapse=False
|
82 |
submit = gr.Button("Submit", variant="primary")
|
83 |
examples = gr.Examples(examples=["data/Jokowi - 2022.mp3", "data/Soekarno - 1963.mp3", "data/JFK.mp3"],
|
@@ -100,7 +131,7 @@ with gr.Blocks() as blocks:
|
|
100 |
# actions
|
101 |
submit.click(
|
102 |
tts,
|
103 |
-
[
|
104 |
[text_source, text_target, audio],
|
105 |
)
|
106 |
radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio)
|
|
|
16 |
info = "This application uses [Indonesian Whisperer Medium](https://huggingface.co/cahya/whisper-medium-id) model"
|
17 |
badge = "https://img.shields.io/badge/Powered%20by-Indonesian%20Whisperer-red"
|
18 |
|
19 |
+
languages = {
|
20 |
+
'English': 'en',
|
21 |
+
'German': 'de',
|
22 |
+
'Spanish': 'es',
|
23 |
+
'French': 'fr',
|
24 |
+
'Portuguese': 'pt',
|
25 |
+
'Polish': 'pl',
|
26 |
+
'Dutch': 'nl',
|
27 |
+
'Swedish': 'sv',
|
28 |
+
'Italian': 'it',
|
29 |
+
'Finnish': 'fi',
|
30 |
+
'Ukrainian': 'uk',
|
31 |
+
'Greek': 'el',
|
32 |
+
'Czech': 'cs',
|
33 |
+
'Romanian': 'ro',
|
34 |
+
'Danish': 'da',
|
35 |
+
'Hungarian': 'hu',
|
36 |
+
'Croatian': 'hr',
|
37 |
+
'Bulgarian': 'bg',
|
38 |
+
'Lithuanian': 'lt',
|
39 |
+
'Slovak': 'sk',
|
40 |
+
'Latvian': 'lv',
|
41 |
+
'Slovenian': 'sl',
|
42 |
+
'Estonian': 'et',
|
43 |
+
'Maltese': 'mt'
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
device = 0 if torch.cuda.is_available() else "cpu"
|
48 |
|
49 |
pipe = pipeline(
|
|
|
55 |
|
56 |
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
57 |
|
58 |
+
|
59 |
def transcribe(microphone, file_upload):
|
60 |
warn_output = ""
|
61 |
if (microphone is not None) and (file_upload is not None):
|
|
|
107 |
choices=LANGUAGES,
|
108 |
value=default_lang
|
109 |
)
|
110 |
+
language = gr.Dropdown([lang for lang in languages.keys()], label="Target Language", value="English")
|
111 |
+
language = languages[language]
|
112 |
with gr.Row(): # mobile_collapse=False
|
113 |
submit = gr.Button("Submit", variant="primary")
|
114 |
examples = gr.Examples(examples=["data/Jokowi - 2022.mp3", "data/Soekarno - 1963.mp3", "data/JFK.mp3"],
|
|
|
131 |
# actions
|
132 |
submit.click(
|
133 |
tts,
|
134 |
+
[language, audio_microphone, audio_upload],
|
135 |
[text_source, text_target, audio],
|
136 |
)
|
137 |
radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio)
|