Update app.py
Browse files
app.py
CHANGED
@@ -29,8 +29,8 @@ def download_from_youtube(youtube_link: str) -> str:
|
|
29 |
return "audio.wav"
|
30 |
|
31 |
|
32 |
-
|
33 |
-
MODEL_NAME = 'Dorjzodovsuren/whisper-large-v3-turbo-mn-2'
|
34 |
lang = 'mn'
|
35 |
|
36 |
chunk_length_s = 9
|
@@ -47,7 +47,7 @@ from transformers import pipeline
|
|
47 |
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
|
48 |
|
49 |
if MODEL_NAME == 'bayartsogt/whisper-large-v2-mn-13':
|
50 |
-
processor = AutoProcessor.from_pretrained(
|
51 |
|
52 |
else:
|
53 |
processor = AutoProcessor.from_pretrained("openai/whisper-large-v3-turbo")
|
@@ -132,4 +132,34 @@ def generator(youtube_link, microphone, file_upload, num_speakers, max_duration,
|
|
132 |
with open(file_name, 'w') as fp:
|
133 |
fp.write(history)
|
134 |
|
135 |
-
yield history, history, file_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
return "audio.wav"
|
30 |
|
31 |
|
32 |
+
MODEL_NAME = 'bayartsogt/whisper-large-v2-mn-13'
|
33 |
+
#MODEL_NAME = 'Dorjzodovsuren/whisper-large-v3-turbo-mn-2'
|
34 |
lang = 'mn'
|
35 |
|
36 |
chunk_length_s = 9
|
|
|
47 |
from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
|
48 |
|
49 |
if MODEL_NAME == 'bayartsogt/whisper-large-v2-mn-13':
|
50 |
+
processor = AutoProcessor.from_pretrained(MODEL_NAME)
|
51 |
|
52 |
else:
|
53 |
processor = AutoProcessor.from_pretrained("openai/whisper-large-v3-turbo")
|
|
|
132 |
with open(file_name, 'w') as fp:
|
133 |
fp.write(history)
|
134 |
|
135 |
+
yield history, history, file_name
|
136 |
+
|
137 |
+
|
138 |
+
demo = gr.Interface(
|
139 |
+
generator,
|
140 |
+
inputs=[
|
141 |
+
gr.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
|
142 |
+
gr.Audio(type="filepath"),
|
143 |
+
gr.Audio(type="filepath"),
|
144 |
+
gr.Number(value=1, label="Number of Speakers"),
|
145 |
+
gr.Number(value=120, label="Maximum Duration (Seconds)"),
|
146 |
+
'state',
|
147 |
+
],
|
148 |
+
outputs=['text', 'state', 'file'],
|
149 |
+
theme="huggingface",
|
150 |
+
title="Transcribe Mongolian Whisper π²π³",
|
151 |
+
description=(
|
152 |
+
"Transcribe Youtube Video / Microphone / Uploaded File in Mongolian Whisper Model." + \
|
153 |
+
" | You can upload SubRip file (`.srt`) [to your youtube video](https://support.google.com/youtube/answer/2734698?hl=en#zippy=%2Cbasic-file-formats)." + \
|
154 |
+
" | Please REFRESH π the page after you transcribed!" + \
|
155 |
+
" | π¦ [@_tsogoo_](https://twitter.com/_tsogoo_)" + \
|
156 |
+
" | π€ [@bayartsogt](https://huggingface.co/bayartsogt)" + \
|
157 |
+
""
|
158 |
+
),
|
159 |
+
allow_flagging="never",
|
160 |
+
)
|
161 |
+
|
162 |
+
# define queue - required for generators
|
163 |
+
demo.queue()
|
164 |
+
|
165 |
+
demo.launch(debug=True)
|