Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from typing import Iterator
|
2 |
-
|
3 |
from io import StringIO
|
4 |
import os
|
5 |
import pathlib
|
@@ -26,25 +26,11 @@ DELETE_UPLOADED_FILES = True
|
|
26 |
MAX_FILE_PREFIX_LENGTH = 17
|
27 |
|
28 |
LANGUAGES = [
|
29 |
-
"English", "
|
30 |
-
"French", "Japanese", "Portuguese", "Turkish", "Polish", "Catalan",
|
31 |
-
"Dutch", "Arabic", "Swedish", "Italian", "Indonesian", "Hindi",
|
32 |
-
"Finnish", "Vietnamese", "Hebrew", "Ukrainian", "Greek", "Malay",
|
33 |
-
"Czech", "Romanian", "Danish", "Hungarian", "Tamil", "Norwegian",
|
34 |
-
"Thai", "Urdu", "Croatian", "Bulgarian", "Lithuanian", "Latin",
|
35 |
-
"Maori", "Malayalam", "Welsh", "Slovak", "Telugu", "Persian",
|
36 |
-
"Latvian", "Bengali", "Serbian", "Azerbaijani", "Slovenian",
|
37 |
-
"Kannada", "Estonian", "Macedonian", "Breton", "Basque", "Icelandic",
|
38 |
-
"Armenian", "Nepali", "Mongolian", "Bosnian", "Kazakh", "Albanian",
|
39 |
-
"Swahili", "Galician", "Marathi", "Punjabi", "Sinhala", "Khmer",
|
40 |
-
"Shona", "Yoruba", "Somali", "Afrikaans", "Occitan", "Georgian",
|
41 |
-
"Belarusian", "Tajik", "Sindhi", "Gujarati", "Amharic", "Yiddish",
|
42 |
-
"Lao", "Uzbek", "Faroese", "Haitian Creole", "Pashto", "Turkmen",
|
43 |
-
"Nynorsk", "Maltese", "Sanskrit", "Luxembourgish", "Myanmar", "Tibetan",
|
44 |
-
"Tagalog", "Malagasy", "Assamese", "Tatar", "Hawaiian", "Lingala",
|
45 |
-
"Hausa", "Bashkir", "Javanese", "Sundanese"
|
46 |
]
|
47 |
|
|
|
|
|
48 |
class WhisperTranscriber:
|
49 |
def __init__(self, inputAudioMaxDuration: float = DEFAULT_INPUT_AUDIO_MAX_DURATION, deleteUploadedFiles: bool = DELETE_UPLOADED_FILES):
|
50 |
self.model_cache = dict()
|
@@ -219,6 +205,8 @@ class WhisperTranscriber:
|
|
219 |
|
220 |
|
221 |
def create_ui(inputAudioMaxDuration, share=False, server_name: str = None):
|
|
|
|
|
222 |
ui = WhisperTranscriber(inputAudioMaxDuration)
|
223 |
|
224 |
ui_description = "Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse "
|
@@ -253,4 +241,16 @@ def create_ui(inputAudioMaxDuration, share=False, server_name: str = None):
|
|
253 |
demo.launch(share=share, server_name=server_name)
|
254 |
|
255 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
create_ui(DEFAULT_INPUT_AUDIO_MAX_DURATION)
|
|
|
1 |
from typing import Iterator
|
2 |
+
import streamlit as st
|
3 |
from io import StringIO
|
4 |
import os
|
5 |
import pathlib
|
|
|
26 |
MAX_FILE_PREFIX_LENGTH = 17
|
27 |
|
28 |
LANGUAGES = [
|
29 |
+
"English", "Spanish", "Portuguese", "Italian", "Hebrew"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
]
|
31 |
|
32 |
+
|
33 |
+
|
34 |
class WhisperTranscriber:
|
35 |
def __init__(self, inputAudioMaxDuration: float = DEFAULT_INPUT_AUDIO_MAX_DURATION, deleteUploadedFiles: bool = DELETE_UPLOADED_FILES):
|
36 |
self.model_cache = dict()
|
|
|
205 |
|
206 |
|
207 |
def create_ui(inputAudioMaxDuration, share=False, server_name: str = None):
|
208 |
+
|
209 |
+
|
210 |
ui = WhisperTranscriber(inputAudioMaxDuration)
|
211 |
|
212 |
ui_description = "Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse "
|
|
|
241 |
demo.launch(share=share, server_name=server_name)
|
242 |
|
243 |
if __name__ == '__main__':
|
244 |
+
uploaded_file = st.file_uploader("Choose a file")
|
245 |
+
if uploaded_file is not None:
|
246 |
+
# To read file as bytes:
|
247 |
+
bytes_data = uploaded_file.getvalue()
|
248 |
+
st.video(bytes_data)
|
249 |
+
os.system("rm -R /tmp/*")
|
250 |
+
os.system("mkdir /tmp/_input")
|
251 |
+
os.system("mkdir /tmp/_output")
|
252 |
+
os.system("mkdir /tmp/_outputf")
|
253 |
+
os.system("mkdir /tmp/videoSaida")
|
254 |
+
with open("/tmp/inputvideo", "wb") as binary_file:
|
255 |
+
binary_file.write(bytes_data)
|
256 |
create_ui(DEFAULT_INPUT_AUDIO_MAX_DURATION)
|