Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import time
|
3 |
from transformers import pipeline
|
4 |
from pytube import YouTube
|
5 |
from pydub import AudioSegment
|
6 |
from audio_extract import extract_audio
|
7 |
import google.generativeai as google_genai
|
|
|
8 |
import os
|
9 |
from dotenv import load_dotenv
|
10 |
|
@@ -34,9 +36,20 @@ def youtube_video_downloader(url):
|
|
34 |
|
35 |
|
36 |
def audio_extraction(video_file):
|
37 |
-
video_file_bytes = os.fsencode(video_file)
|
38 |
-
audio = extract_audio(input_path=video_file_bytes, output_path=f"{video_file}.mp3")
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
def audio_processing(mp3_audio):
|
|
|
1 |
import streamlit as st
|
2 |
+
from moviepy.editor import VideoFileClip
|
3 |
import time
|
4 |
from transformers import pipeline
|
5 |
from pytube import YouTube
|
6 |
from pydub import AudioSegment
|
7 |
from audio_extract import extract_audio
|
8 |
import google.generativeai as google_genai
|
9 |
+
|
10 |
import os
|
11 |
from dotenv import load_dotenv
|
12 |
|
|
|
36 |
|
37 |
|
38 |
def audio_extraction(video_file):
|
39 |
+
# video_file_bytes = os.fsencode(video_file)
|
40 |
+
# audio = extract_audio(input_path=video_file_bytes, output_path=f"{video_file}.mp3")
|
41 |
+
video = VideoFileClip(video_file)
|
42 |
+
|
43 |
+
# Extract the audio from the video
|
44 |
+
audio = video.audio
|
45 |
+
|
46 |
+
# Write the audio to a file
|
47 |
+
audio_path = 'audio.mp3'
|
48 |
+
audio.write_audiofile(audio_path)
|
49 |
+
|
50 |
+
# Close the video file
|
51 |
+
video.close()
|
52 |
+
return audio_path
|
53 |
|
54 |
|
55 |
def audio_processing(mp3_audio):
|