Spaces:
Sleeping
Sleeping
Shashwat2528
commited on
Commit
·
a264185
1
Parent(s):
aec05f5
Update app.py
Browse files
app.py
CHANGED
@@ -2,10 +2,12 @@ import gradio as gr
|
|
2 |
from transformers import pipeline
|
3 |
from gtts import gTTS
|
4 |
import tempfile
|
|
|
|
|
5 |
|
6 |
# Load the question-answering model
|
7 |
model_name = "AVISHKAARAM/avishkaarak-ekta-hindi"
|
8 |
-
model = pipeline("question-answering", model=model_name
|
9 |
|
10 |
def question_answering(context, question):
|
11 |
# Use the question-answering model to get the answer
|
@@ -19,12 +21,21 @@ def question_answering(context, question):
|
|
19 |
|
20 |
return answer, audio_path
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Create the Gradio interface
|
23 |
iface = gr.Interface(
|
24 |
fn=question_answering,
|
25 |
inputs=["text", "text"],
|
26 |
-
outputs=[
|
27 |
-
|
|
|
|
|
28 |
title="Question Answering - AVISHKAARAK",
|
29 |
description="Enter a context and a question to get an answer. :)",
|
30 |
examples=[
|
@@ -34,5 +45,4 @@ iface = gr.Interface(
|
|
34 |
)
|
35 |
|
36 |
# Run the interface
|
37 |
-
iface.launch()
|
38 |
-
|
|
|
2 |
from transformers import pipeline
|
3 |
from gtts import gTTS
|
4 |
import tempfile
|
5 |
+
import pygame
|
6 |
+
import time
|
7 |
|
8 |
# Load the question-answering model
|
9 |
model_name = "AVISHKAARAM/avishkaarak-ekta-hindi"
|
10 |
+
model = pipeline("question-answering", model=model_name)
|
11 |
|
12 |
def question_answering(context, question):
|
13 |
# Use the question-answering model to get the answer
|
|
|
21 |
|
22 |
return answer, audio_path
|
23 |
|
24 |
+
def play_audio(audio_path):
|
25 |
+
pygame.mixer.init()
|
26 |
+
pygame.mixer.music.load(audio_path)
|
27 |
+
pygame.mixer.music.play()
|
28 |
+
while pygame.mixer.music.get_busy():
|
29 |
+
time.sleep(0.1)
|
30 |
+
|
31 |
# Create the Gradio interface
|
32 |
iface = gr.Interface(
|
33 |
fn=question_answering,
|
34 |
inputs=["text", "text"],
|
35 |
+
outputs=[
|
36 |
+
gr.outputs.Textbox(label="Answer"),
|
37 |
+
gr.outputs.Audio(label="Answer Audio", type="numpy")
|
38 |
+
],
|
39 |
title="Question Answering - AVISHKAARAK",
|
40 |
description="Enter a context and a question to get an answer. :)",
|
41 |
examples=[
|
|
|
45 |
)
|
46 |
|
47 |
# Run the interface
|
48 |
+
iface.launch()
|
|