FarhadMadadzade
commited on
Commit
•
be37f4c
1
Parent(s):
23c3af4
trying again
Browse files
app.py
CHANGED
@@ -11,15 +11,12 @@ from pydub.silence import split_on_silence
|
|
11 |
pipe = pipeline("automatic-speech-recognition", model="Artanis1551/whisper_romanian3")
|
12 |
|
13 |
|
14 |
-
def process_video(date,
|
15 |
-
# Parse the date to the format yyyymmdd
|
16 |
-
date = datetime.datetime.strptime(date, "%Y-%m-%d").strftime("%Y%m%d")
|
17 |
-
|
18 |
# Download the video
|
19 |
video_path = download_video(date)
|
20 |
|
21 |
-
#
|
22 |
-
|
23 |
|
24 |
# Extract audio from the video
|
25 |
audio_path = f"audio_{date}.wav"
|
@@ -35,15 +32,17 @@ def process_video(date, live):
|
|
35 |
chunk.export(f"chunk{i}.wav", format="wav")
|
36 |
with open(f"chunk{i}.wav", "rb") as audio_file:
|
37 |
audio = audio_file.read()
|
38 |
-
transcription += pipe(audio)["text"] + "
|
39 |
os.remove(f"chunk{i}.wav")
|
40 |
|
41 |
-
# Update the
|
42 |
-
|
43 |
|
44 |
# Remove the audio file
|
45 |
os.remove(audio_path)
|
46 |
|
|
|
|
|
47 |
|
48 |
iface = gr.Interface(
|
49 |
fn=process_video,
|
|
|
11 |
pipe = pipeline("automatic-speech-recognition", model="Artanis1551/whisper_romanian3")
|
12 |
|
13 |
|
14 |
+
def process_video(date, update_fn):
|
|
|
|
|
|
|
15 |
# Download the video
|
16 |
video_path = download_video(date)
|
17 |
|
18 |
+
# Update the output with the video
|
19 |
+
update_fn(video=video_path)
|
20 |
|
21 |
# Extract audio from the video
|
22 |
audio_path = f"audio_{date}.wav"
|
|
|
32 |
chunk.export(f"chunk{i}.wav", format="wav")
|
33 |
with open(f"chunk{i}.wav", "rb") as audio_file:
|
34 |
audio = audio_file.read()
|
35 |
+
transcription += pipe(audio)["text"] + " "
|
36 |
os.remove(f"chunk{i}.wav")
|
37 |
|
38 |
+
# Update the output with the transcription
|
39 |
+
update_fn(transcription=transcription)
|
40 |
|
41 |
# Remove the audio file
|
42 |
os.remove(audio_path)
|
43 |
|
44 |
+
return video_path, transcription
|
45 |
+
|
46 |
|
47 |
iface = gr.Interface(
|
48 |
fn=process_video,
|