Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,22 @@ import json
|
|
2 |
import ffmpeg
|
3 |
from subprocess import run
|
4 |
import gradio as gr
|
|
|
|
|
|
|
5 |
import whisper_timestamped as whisper
|
6 |
from transformers import pipeline
|
7 |
|
8 |
model = whisper.load_model("small", device="cpu")
|
9 |
sentiment_analysis = pipeline("sentiment-analysis", framework="pt", model="SamLowe/roberta-base-go_emotions", use_fast=True)
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
def analyze_sentiment(text):
|
12 |
results = sentiment_analysis(text)
|
13 |
sentiment_results = {result['label']: result['score'] for result in results}
|
@@ -24,7 +34,9 @@ def transcribe(audio):
|
|
24 |
|
25 |
|
26 |
def video_to_audio(input_video, output_audio):
|
27 |
-
|
|
|
|
|
28 |
run(["ffmpeg", "-i", 'test_video_1.mp4', audio_file])
|
29 |
|
30 |
response = transcribe(audio=audio_file)
|
|
|
2 |
import ffmpeg
|
3 |
from subprocess import run
|
4 |
import gradio as gr
|
5 |
+
import uuid
|
6 |
+
import os
|
7 |
+
from zipfile import ZipFile
|
8 |
import whisper_timestamped as whisper
|
9 |
from transformers import pipeline
|
10 |
|
11 |
model = whisper.load_model("small", device="cpu")
|
12 |
sentiment_analysis = pipeline("sentiment-analysis", framework="pt", model="SamLowe/roberta-base-go_emotions", use_fast=True)
|
13 |
|
14 |
+
ZipFile("ffmpeg.zip").extractall()
|
15 |
+
st = os.stat('ffmpeg')
|
16 |
+
os.chmod('ffmpeg', st.st_mode | stat.S_IEXEC)
|
17 |
+
|
18 |
+
print("cwd", os.getcwd())
|
19 |
+
print(os.listdir())
|
20 |
+
|
21 |
def analyze_sentiment(text):
|
22 |
results = sentiment_analysis(text)
|
23 |
sentiment_results = {result['label']: result['score'] for result in results}
|
|
|
34 |
|
35 |
|
36 |
def video_to_audio(input_video, output_audio):
|
37 |
+
current_path = os.getcwd()
|
38 |
+
common_uuid = uuid.uuid4()
|
39 |
+
audio_file = f"{common_uuid}.wav"
|
40 |
run(["ffmpeg", "-i", 'test_video_1.mp4', audio_file])
|
41 |
|
42 |
response = transcribe(audio=audio_file)
|