Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,6 @@ import whisper
|
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
8 |
-
# Set ffmpeg path for the Docker container environment
|
9 |
-
ffmpeg_path = '/usr/bin/ffmpeg'
|
10 |
-
if not os.path.isfile(ffmpeg_path):
|
11 |
-
raise FileNotFoundError(f"FFmpeg binary not found at {ffmpeg_path}")
|
12 |
-
|
13 |
# Load the Whisper model
|
14 |
model = whisper.load_model("medium") # Change to "large" for the most accurate model
|
15 |
|
@@ -54,19 +49,21 @@ def extract_audio(video_path):
|
|
54 |
video = VideoFileClip(video_path)
|
55 |
video.audio.write_audiofile(audio_path)
|
56 |
return audio_path
|
57 |
-
|
58 |
def transcribe_audio(audio_path):
|
59 |
print(f"Transcribing audio from: {audio_path}")
|
60 |
if not os.path.exists(audio_path):
|
61 |
raise FileNotFoundError(f"Audio file not found at {audio_path}")
|
62 |
|
63 |
try:
|
64 |
-
|
65 |
-
print("
|
|
|
66 |
except Exception as e:
|
67 |
-
print(f"
|
68 |
raise
|
69 |
|
|
|
70 |
try:
|
71 |
result = model.transcribe(audio_path)
|
72 |
print(f"Transcription result: {result}")
|
@@ -78,4 +75,4 @@ def transcribe_audio(audio_path):
|
|
78 |
if __name__ == '__main__':
|
79 |
if not os.path.exists('uploads'):
|
80 |
os.makedirs('uploads')
|
81 |
-
app.run(debug=True, host='0.0.0.0', port=80)
|
|
|
5 |
|
6 |
app = Flask(__name__)
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
# Load the Whisper model
|
9 |
model = whisper.load_model("medium") # Change to "large" for the most accurate model
|
10 |
|
|
|
49 |
video = VideoFileClip(video_path)
|
50 |
video.audio.write_audiofile(audio_path)
|
51 |
return audio_path
|
52 |
+
|
53 |
def transcribe_audio(audio_path):
|
54 |
print(f"Transcribing audio from: {audio_path}")
|
55 |
if not os.path.exists(audio_path):
|
56 |
raise FileNotFoundError(f"Audio file not found at {audio_path}")
|
57 |
|
58 |
try:
|
59 |
+
result = model.transcribe(audio_path)
|
60 |
+
print(f"Transcription result: {result}")
|
61 |
+
return result["text"]
|
62 |
except Exception as e:
|
63 |
+
print(f"Error during transcription: {e}")
|
64 |
raise
|
65 |
|
66 |
+
|
67 |
try:
|
68 |
result = model.transcribe(audio_path)
|
69 |
print(f"Transcription result: {result}")
|
|
|
75 |
if __name__ == '__main__':
|
76 |
if not os.path.exists('uploads'):
|
77 |
os.makedirs('uploads')
|
78 |
+
app.run(debug=True, host='0.0.0.0', port=80)
|