Spaces:
Sleeping
Sleeping
File size: 1,402 Bytes
582ce89 723db0a 582ce89 723db0a fb08a96 c8f2dae 582ce89 c8f2dae 582ce89 c8f2dae 9fa05d5 582ce89 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
import cv2
import pytube
import gradio as gr
from main import predict_mcq
from youtube_transcript_api import YouTubeTranscriptApi as yt
def YtToQuizz(link):
video_id=pytube.extract.video_id(link)
transcript=yt.get_transcript(video_id)
data=""
for text in transcript:
data+=text.get('text')
return data
def put_in_single_list(data):
result=[]
final_result=[]
for i in data:
result.append(i.get("question_statement"))
result.append(i.get("answer"))
result.append(i.get("options"))
final_result.append(result)
return final_result
def MCQGenerator(url):
I_text=YtToQuizz(url)
text={
"input_text":I_text
}
Mcqs=predict_mcq(text)
data=Mcqs.get('questions')
print(data)
if data is not None:
#final_result=put_in_single_list(data)
statement=""
answer=""
options=""
for mcq in data:
statement+=mcq.get('question_statement')+','
answer+=mcq.get('answer')+','
options+=mcq.get('options')[0]+','+mcq.get('options')[1]+','+mcq.get('options')[2]+','
return statement,answer,options
else:
return "Null","Null","Null"
iface=gr.Interface(fn=MCQGenerator,inputs=[gr.components.Textbox(label="Enter YouTube Link")],outputs=[gr.components.Textbox(label="Question"),gr.components.Textbox(label="Answer"),gr.components.Textbox(label="Options")],
)
iface.launch(debug=True) |