Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,15 @@ import os
|
|
2 |
import subprocess
|
3 |
import sys
|
4 |
import nltk
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Check if the question_generation directory exists; if not, clone the repository
|
8 |
if not os.path.exists("question_generation"):
|
@@ -15,19 +23,6 @@ sys.path.append(os.path.join(os.path.dirname(__file__), 'question_generation'))
|
|
15 |
# Download the punkt tokenizer
|
16 |
nltk.download('punkt')
|
17 |
|
18 |
-
|
19 |
-
# Continue with the rest of your imports and app logic
|
20 |
-
import whisper
|
21 |
-
import torch
|
22 |
-
from transformers import pipeline
|
23 |
-
from transformers.utils import logging
|
24 |
-
from langdetect import detect
|
25 |
-
import gradio as gr
|
26 |
-
from gtts import gTTS
|
27 |
-
from moviepy.editor import VideoFileClip
|
28 |
-
import yt_dlp
|
29 |
-
|
30 |
-
|
31 |
# Set logging verbosity
|
32 |
logging.set_verbosity_error()
|
33 |
|
@@ -51,7 +46,13 @@ qa_pipeline = pipeline(task="question-answering", model="deepset/roberta-base-sq
|
|
51 |
|
52 |
# Load question generator
|
53 |
from pipelines import pipeline
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# Function to download audio from YouTube
|
57 |
def download_audio_from_youtube(youtube_url, output_path="downloaded_audio.mp3"):
|
|
|
2 |
import subprocess
|
3 |
import sys
|
4 |
import nltk
|
5 |
+
import whisper
|
6 |
+
import torch
|
7 |
+
from transformers import pipeline
|
8 |
+
from transformers.utils import logging
|
9 |
+
from langdetect import detect
|
10 |
+
import gradio as gr
|
11 |
+
from gtts import gTTS
|
12 |
+
from moviepy.editor import VideoFileClip
|
13 |
+
import yt_dlp
|
14 |
|
15 |
# Check if the question_generation directory exists; if not, clone the repository
|
16 |
if not os.path.exists("question_generation"):
|
|
|
23 |
# Download the punkt tokenizer
|
24 |
nltk.download('punkt')
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# Set logging verbosity
|
27 |
logging.set_verbosity_error()
|
28 |
|
|
|
46 |
|
47 |
# Load question generator
|
48 |
from pipelines import pipeline
|
49 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
50 |
+
|
51 |
+
# Load the tokenizer and model
|
52 |
+
tokenizer = AutoTokenizer.from_pretrained("valhalla/t5-small-qg-prepend", use_fast=False) # Disable the fast tokenizer
|
53 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("valhalla/t5-small-qg-prepend")
|
54 |
+
|
55 |
+
question_generator = pipeline("question-generation", model=model, tokenizer=tokenizer, qg_format="prepend")
|
56 |
|
57 |
# Function to download audio from YouTube
|
58 |
def download_audio_from_youtube(youtube_url, output_path="downloaded_audio.mp3"):
|