Spaces:
Running
Running
abrar-adnan
commited on
Commit
•
b45a874
1
Parent(s):
5118e25
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from fastai.vision.all import load_learner
|
|
6 |
import time
|
7 |
import base64
|
8 |
from deepface import DeepFace
|
|
|
9 |
|
10 |
# import pathlib
|
11 |
# temp = pathlib.PosixPath
|
@@ -42,6 +43,20 @@ def video_processing(video_file, encoded_video):
|
|
42 |
video_file = "temp_video.mp4"
|
43 |
|
44 |
start_time = time.time()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
video_capture = cv2.VideoCapture(video_file)
|
47 |
on_camera = 0
|
|
|
6 |
import time
|
7 |
import base64
|
8 |
from deepface import DeepFace
|
9 |
+
import torchaudio, torch
|
10 |
|
11 |
# import pathlib
|
12 |
# temp = pathlib.PosixPath
|
|
|
43 |
video_file = "temp_video.mp4"
|
44 |
|
45 |
start_time = time.time()
|
46 |
+
|
47 |
+
subprocess.call(["ffmpeg", "-i", 'source_videos/A message from longbeachgriffy.mp4', "audio.wav"])
|
48 |
+
waveform, sample_rate = torchaudio.load("audio.wav")
|
49 |
+
waveform, sample_rate
|
50 |
+
|
51 |
+
waveform, sample_rate = torchaudio.load("audio.wav")
|
52 |
+
resampler = torchaudio.transforms.Resample(sample_rate, 16000)
|
53 |
+
waveform = resampler(waveform)[0]
|
54 |
+
|
55 |
+
input_features = processor(waveform.squeeze(dim=0), return_tensors="pt").input_features
|
56 |
+
predicted_ids = model.generate(input_features)
|
57 |
+
|
58 |
+
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
59 |
+
print(transcription[0])
|
60 |
|
61 |
video_capture = cv2.VideoCapture(video_file)
|
62 |
on_camera = 0
|