Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,6 @@ transcriber = pipeline(model="openai/whisper-base")
|
|
9 |
# Load summarization model
|
10 |
summarization_model = pipeline("summarization")
|
11 |
|
12 |
-
# Load question-answering model
|
13 |
-
model_name = "deepset/roberta-base-squad2"
|
14 |
-
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
15 |
-
|
16 |
def translate_audio(audio):
|
17 |
# Step 1: Transcribe audio to text
|
18 |
transcription = transcriber(audio)
|
@@ -24,13 +20,6 @@ def translate_audio(audio):
|
|
24 |
|
25 |
return transcription['text'], summary[0]['summary_text']
|
26 |
|
27 |
-
def answer_question(context, question):
|
28 |
-
QA_input = {
|
29 |
-
'question': question,
|
30 |
-
'context': context
|
31 |
-
}
|
32 |
-
print('----QA_input----', QA_input)
|
33 |
-
return nlp(QA_input)['answer']
|
34 |
|
35 |
# Create Gradio interface
|
36 |
with gr.Blocks() as iface:
|
@@ -53,19 +42,5 @@ with gr.Blocks() as iface:
|
|
53 |
outputs=[transcription_output, translation_output]
|
54 |
)
|
55 |
|
56 |
-
def respond(message, chat_history, context):
|
57 |
-
bot_message = answer_question(context, message)
|
58 |
-
print('----bot_message---', bot_message)
|
59 |
-
chat_history.append((message, bot_message))
|
60 |
-
time.sleep(2)
|
61 |
-
return "", chat_history
|
62 |
-
|
63 |
-
with gr.Blocks() as demo:
|
64 |
-
chatbot = gr.Chatbot()
|
65 |
-
msg = gr.Textbox()
|
66 |
-
clear = gr.ClearButton([msg, chatbot])
|
67 |
-
|
68 |
-
msg.submit(respond, [msg, chatbot, transcription_output], [msg, chatbot])
|
69 |
-
|
70 |
# Launch the app
|
71 |
iface.launch(share=True) # 'share=True' to get a public link
|
|
|
9 |
# Load summarization model
|
10 |
summarization_model = pipeline("summarization")
|
11 |
|
|
|
|
|
|
|
|
|
12 |
def translate_audio(audio):
|
13 |
# Step 1: Transcribe audio to text
|
14 |
transcription = transcriber(audio)
|
|
|
20 |
|
21 |
return transcription['text'], summary[0]['summary_text']
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Create Gradio interface
|
25 |
with gr.Blocks() as iface:
|
|
|
42 |
outputs=[transcription_output, translation_output]
|
43 |
)
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Launch the app
|
46 |
iface.launch(share=True) # 'share=True' to get a public link
|