Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
-
import whisper
|
2 |
import gradio as gr
|
3 |
import subprocess
|
|
|
4 |
|
5 |
# Load the Whisper model
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
raise e
|
11 |
|
12 |
def transcribe_video(video_path):
|
13 |
try:
|
@@ -20,7 +20,12 @@ def transcribe_video(video_path):
|
|
20 |
|
21 |
# Transcribe the audio in Urdu
|
22 |
result = model.transcribe(audio_path, task="transcribe", language="ur")
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
except FileNotFoundError:
|
26 |
return "Error: ffmpeg is not installed or not found in the environment."
|
@@ -31,9 +36,9 @@ def transcribe_video(video_path):
|
|
31 |
interface = gr.Interface(
|
32 |
fn=transcribe_video,
|
33 |
inputs=gr.Video(label="Upload your Urdu-speaking video"),
|
34 |
-
outputs=gr.Textbox(label="Transcribed Text"),
|
35 |
-
title="Urdu Video Transcription
|
36 |
-
description="Upload a video file in Urdu, and this app will transcribe the speech
|
37 |
)
|
38 |
|
39 |
# Launch the app
|
|
|
1 |
+
import whisper
|
2 |
import gradio as gr
|
3 |
import subprocess
|
4 |
+
from autocorrect import Speller
|
5 |
|
6 |
# Load the Whisper model
|
7 |
+
model = whisper.load_model("large")
|
8 |
+
|
9 |
+
# Initialize autocorrect for Urdu
|
10 |
+
spell = Speller(lang='ur') # Set the language for Urdu
|
|
|
11 |
|
12 |
def transcribe_video(video_path):
|
13 |
try:
|
|
|
20 |
|
21 |
# Transcribe the audio in Urdu
|
22 |
result = model.transcribe(audio_path, task="transcribe", language="ur")
|
23 |
+
transcribed_text = result["text"]
|
24 |
+
|
25 |
+
# Correct the transcribed text using autocorrect
|
26 |
+
corrected_text = spell(transcribed_text)
|
27 |
+
|
28 |
+
return corrected_text
|
29 |
|
30 |
except FileNotFoundError:
|
31 |
return "Error: ffmpeg is not installed or not found in the environment."
|
|
|
36 |
interface = gr.Interface(
|
37 |
fn=transcribe_video,
|
38 |
inputs=gr.Video(label="Upload your Urdu-speaking video"),
|
39 |
+
outputs=gr.Textbox(label="Corrected Transcribed Text"),
|
40 |
+
title="Urdu Video Transcription with Correction",
|
41 |
+
description="Upload a video file in Urdu, and this app will transcribe the speech and correct the text using Whisper and autocorrect.",
|
42 |
)
|
43 |
|
44 |
# Launch the app
|