Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -46,6 +46,14 @@ def transcribe_audio(file_path):
|
|
46 |
video = mp.VideoFileClip(file_path)
|
47 |
temp_audio = generate_unique_filename(".mp3")
|
48 |
video.audio.write_audiofile(temp_audio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
#file_path = temp_audio
|
50 |
except Exception as e:
|
51 |
print(f"Error extracting audio from video: {e}")
|
@@ -62,13 +70,7 @@ def transcribe_audio(file_path):
|
|
62 |
print(f"File content: {file_path}")
|
63 |
#time.sleep(5)
|
64 |
|
65 |
-
|
66 |
-
print(f"Transcription : {transcription[:10]}")
|
67 |
-
|
68 |
-
if "text" in transcription:
|
69 |
-
result = transcription["text"]
|
70 |
-
else:
|
71 |
-
result = " ".join([chunk["text"] for chunk in transcription.get("chunks", [])])
|
72 |
|
73 |
except ConnectionResetError as e:
|
74 |
print(f"Connection error occurred: {e}")
|
|
|
46 |
video = mp.VideoFileClip(file_path)
|
47 |
temp_audio = generate_unique_filename(".mp3")
|
48 |
video.audio.write_audiofile(temp_audio)
|
49 |
+
model = whisper.load_model("base")
|
50 |
+
transcription = model.transcribe(temp_audio)
|
51 |
+
#print(f"Transcription : {transcription[:10]}")
|
52 |
+
|
53 |
+
if "text" in transcription:
|
54 |
+
result = transcription["text"]
|
55 |
+
else:
|
56 |
+
result = " ".join([chunk["text"] for chunk in transcription.get("chunks", [])])
|
57 |
#file_path = temp_audio
|
58 |
except Exception as e:
|
59 |
print(f"Error extracting audio from video: {e}")
|
|
|
70 |
print(f"File content: {file_path}")
|
71 |
#time.sleep(5)
|
72 |
|
73 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
except ConnectionResetError as e:
|
76 |
print(f"Connection error occurred: {e}")
|