Spaces:
Runtime error
Runtime error
bayartsogt
commited on
Commit
Β·
5673c7d
1
Parent(s):
68c958a
sbv -> srt
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ from pyannote.audio import Pipeline
|
|
5 |
from transformers import pipeline
|
6 |
from utils import second_to_timecode, download_from_youtube
|
7 |
|
8 |
-
MODEL_NAME = 'bayartsogt/whisper-
|
9 |
lang = 'mn'
|
10 |
|
11 |
chunk_length_s = 9
|
@@ -60,21 +60,24 @@ def generator(youtube_link, microphone, file_upload, num_speakers, max_duration,
|
|
60 |
vad_start = _start + int(sampling_rate * vad_turn.start)
|
61 |
vad_end = _start + int(sampling_rate * vad_turn.end)
|
62 |
prediction = pipe(waveform[vad_start: vad_end])['text']
|
63 |
-
history += f"{
|
|
|
64 |
f"{prediction}\n\n"
|
65 |
# f">> {speaker}: {prediction}\n\n"
|
66 |
yield history, history, None
|
|
|
67 |
|
68 |
else:
|
69 |
prediction = pipe(data)['text']
|
70 |
-
history += f"{
|
|
|
71 |
f"{prediction}\n\n"
|
72 |
# f">> {speaker}: {prediction}\n\n"
|
73 |
-
|
74 |
-
|
75 |
|
76 |
# https://support.google.com/youtube/answer/2734698?hl=en#zippy=%2Cbasic-file-formats%2Csubrip-srt-example%2Csubviewer-sbv-example
|
77 |
-
file_name = 'transcript.
|
78 |
with open(file_name, 'w') as fp:
|
79 |
fp.write(history)
|
80 |
|
@@ -96,7 +99,7 @@ demo = gr.Interface(
|
|
96 |
title="Transcribe Mongolian Whisper π²π³",
|
97 |
description=(
|
98 |
"Transcribe Youtube Video / Microphone / Uploaded File in Mongolian Whisper Model." + \
|
99 |
-
" | You can upload
|
100 |
" | Please REFRESH π the page after you transcribed!" + \
|
101 |
" | π¦ [@_tsogoo_](https://twitter.com/_tsogoo_)" + \
|
102 |
" | π€ [@bayartsogt](https://huggingface.co/bayartsogt)" + \
|
|
|
5 |
from transformers import pipeline
|
6 |
from utils import second_to_timecode, download_from_youtube
|
7 |
|
8 |
+
MODEL_NAME = 'bayartsogt/whisper-large-v2-mn-13'
|
9 |
lang = 'mn'
|
10 |
|
11 |
chunk_length_s = 9
|
|
|
60 |
vad_start = _start + int(sampling_rate * vad_turn.start)
|
61 |
vad_end = _start + int(sampling_rate * vad_turn.end)
|
62 |
prediction = pipe(waveform[vad_start: vad_end])['text']
|
63 |
+
history += f"{counter}\n" + \
|
64 |
+
f"{second_to_timecode(speech_turn.start + vad_turn.start)} --> {second_to_timecode(speech_turn.start + vad_turn.end)}\n" + \
|
65 |
f"{prediction}\n\n"
|
66 |
# f">> {speaker}: {prediction}\n\n"
|
67 |
yield history, history, None
|
68 |
+
counter += 1
|
69 |
|
70 |
else:
|
71 |
prediction = pipe(data)['text']
|
72 |
+
history += f"{counter}\n" + \
|
73 |
+
f"{second_to_timecode(speech_turn.start)} --> {second_to_timecode(speech_turn.end)}\n" + \
|
74 |
f"{prediction}\n\n"
|
75 |
# f">> {speaker}: {prediction}\n\n"
|
76 |
+
counter += 1
|
77 |
+
yield history, history, None
|
78 |
|
79 |
# https://support.google.com/youtube/answer/2734698?hl=en#zippy=%2Cbasic-file-formats%2Csubrip-srt-example%2Csubviewer-sbv-example
|
80 |
+
file_name = 'transcript.srt'
|
81 |
with open(file_name, 'w') as fp:
|
82 |
fp.write(history)
|
83 |
|
|
|
99 |
title="Transcribe Mongolian Whisper π²π³",
|
100 |
description=(
|
101 |
"Transcribe Youtube Video / Microphone / Uploaded File in Mongolian Whisper Model." + \
|
102 |
+
" | You can upload SubRip file (`.srt`) [to your youtube video](https://support.google.com/youtube/answer/2734698?hl=en#zippy=%2Cbasic-file-formats)." + \
|
103 |
" | Please REFRESH π the page after you transcribed!" + \
|
104 |
" | π¦ [@_tsogoo_](https://twitter.com/_tsogoo_)" + \
|
105 |
" | π€ [@bayartsogt](https://huggingface.co/bayartsogt)" + \
|