Spaces:
Running
Running
Update app.py (#1)
Browse files- Update app.py (f14dd37c07d098ab58f1512184ca2e5600f2e5d5)
app.py
CHANGED
@@ -1,19 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import whisper
|
3 |
import os
|
4 |
-
from moviepy.editor import VideoFileClip
|
5 |
from pydub import AudioSegment
|
6 |
-
import numpy as np
|
7 |
-
|
8 |
-
model = whisper.load_model("base")
|
9 |
|
10 |
def convert_video_to_audio(video_file):
|
11 |
-
video = VideoFileClip(video_file)
|
12 |
-
audio = video.audio
|
13 |
audio_file = video_file.rsplit('.', 1)[0] + ".wav"
|
14 |
-
audio.
|
|
|
15 |
return audio_file
|
16 |
-
|
17 |
def chunk_audio(audio_file, chunk_size_mb=25, max_duration_seconds=900):
|
18 |
audio = AudioSegment.from_file(audio_file)
|
19 |
chunk_size_bytes = chunk_size_mb * 1024 * 1024
|
@@ -23,6 +18,8 @@ def chunk_audio(audio_file, chunk_size_mb=25, max_duration_seconds=900):
|
|
23 |
return [audio[:chunk_duration_ms]]
|
24 |
else:
|
25 |
return [audio]
|
|
|
|
|
26 |
|
27 |
def transcribe_audio(file):
|
28 |
if file is None:
|
|
|
1 |
import gradio as gr
|
2 |
import whisper
|
3 |
import os
|
|
|
4 |
from pydub import AudioSegment
|
|
|
|
|
|
|
5 |
|
6 |
def convert_video_to_audio(video_file):
|
|
|
|
|
7 |
audio_file = video_file.rsplit('.', 1)[0] + ".wav"
|
8 |
+
audio = AudioSegment.from_file(video_file)
|
9 |
+
audio.export(audio_file, format="wav")
|
10 |
return audio_file
|
11 |
+
|
12 |
def chunk_audio(audio_file, chunk_size_mb=25, max_duration_seconds=900):
|
13 |
audio = AudioSegment.from_file(audio_file)
|
14 |
chunk_size_bytes = chunk_size_mb * 1024 * 1024
|
|
|
18 |
return [audio[:chunk_duration_ms]]
|
19 |
else:
|
20 |
return [audio]
|
21 |
+
|
22 |
+
model = whisper.load_model("base")
|
23 |
|
24 |
def transcribe_audio(file):
|
25 |
if file is None:
|