Spaces:
Sleeping
Sleeping
commit
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ from pytube import YouTube
|
|
3 |
from moviepy.editor import *
|
4 |
import speech_recognition as sr
|
5 |
from transformers import pipeline
|
|
|
|
|
6 |
|
7 |
def download_and_extract_audio(youtube_link):
|
8 |
yt = YouTube(youtube_link)
|
@@ -11,7 +13,12 @@ def download_and_extract_audio(youtube_link):
|
|
11 |
base, ext = os.path.splitext(out_file)
|
12 |
new_file = base + '.mp3'
|
13 |
os.rename(out_file, new_file)
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
def transcribe_audio(audio_path):
|
17 |
recognizer = sr.Recognizer()
|
|
|
3 |
from moviepy.editor import *
|
4 |
import speech_recognition as sr
|
5 |
from transformers import pipeline
|
6 |
+
from pydub import AudioSegment
|
7 |
+
import os
|
8 |
|
9 |
def download_and_extract_audio(youtube_link):
|
10 |
yt = YouTube(youtube_link)
|
|
|
13 |
base, ext = os.path.splitext(out_file)
|
14 |
new_file = base + '.mp3'
|
15 |
os.rename(out_file, new_file)
|
16 |
+
|
17 |
+
# Convert MP3 to WAV for compatibility with speech_recognition
|
18 |
+
audio = AudioSegment.from_mp3(new_file)
|
19 |
+
wav_file = base + '.wav'
|
20 |
+
audio.export(wav_file, format="wav")
|
21 |
+
return wav_file
|
22 |
|
23 |
def transcribe_audio(audio_path):
|
24 |
recognizer = sr.Recognizer()
|