Update app.py
Browse files
app.py
CHANGED
@@ -6,26 +6,29 @@ from transformers import (
|
|
6 |
from textblob import TextBlob as tb
|
7 |
import gradio as gr
|
8 |
|
|
|
9 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
|
10 |
model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
|
11 |
pipe = pipeline(model="aware-ai/whisper-base-german")
|
12 |
|
13 |
|
14 |
-
|
15 |
def translate(text):
|
16 |
blob = tb(text)
|
17 |
translation = str(blob.translate(from_lang='de',to='en'))
|
18 |
return translation
|
19 |
|
|
|
20 |
def translate_to_de(text):
|
21 |
blob = tb(text)
|
22 |
translation = str(blob.translate(from_lang='en',to='de'))
|
23 |
return translation
|
24 |
|
|
|
25 |
def transcribe(audio):
|
26 |
text = pipe(audio)["text"]
|
27 |
return text
|
28 |
|
|
|
29 |
def generate(input, knowledge):
|
30 |
|
31 |
if knowledge == '':
|
@@ -59,12 +62,12 @@ with gr.Blocks() as app:
|
|
59 |
|
60 |
conocimiento = gr.Textbox(label='Conocimiento',lines=7,max_lines=7)
|
61 |
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
button2 = gr.Button(value='Respuesta de la IA')
|
66 |
-
|
67 |
transc = gr.Textbox(label='Transcripción',value='',)
|
|
|
|
|
68 |
respuesta = gr.Textbox(label='Respuesta',interactive=False,value='')
|
69 |
|
70 |
send_button.click(fn=transcribe,inputs=voice,outputs=transc)
|
|
|
6 |
from textblob import TextBlob as tb
|
7 |
import gradio as gr
|
8 |
|
9 |
+
|
10 |
tokenizer = AutoTokenizer.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
|
11 |
model = AutoModelForSeq2SeqLM.from_pretrained("microsoft/GODEL-v1_1-base-seq2seq")
|
12 |
pipe = pipeline(model="aware-ai/whisper-base-german")
|
13 |
|
14 |
|
|
|
15 |
def translate(text):
|
16 |
blob = tb(text)
|
17 |
translation = str(blob.translate(from_lang='de',to='en'))
|
18 |
return translation
|
19 |
|
20 |
+
|
21 |
def translate_to_de(text):
|
22 |
blob = tb(text)
|
23 |
translation = str(blob.translate(from_lang='en',to='de'))
|
24 |
return translation
|
25 |
|
26 |
+
|
27 |
def transcribe(audio):
|
28 |
text = pipe(audio)["text"]
|
29 |
return text
|
30 |
|
31 |
+
|
32 |
def generate(input, knowledge):
|
33 |
|
34 |
if knowledge == '':
|
|
|
62 |
|
63 |
conocimiento = gr.Textbox(label='Conocimiento',lines=7,max_lines=7)
|
64 |
|
65 |
+
voice = gr.Audio(source='microphone',type='filepath')
|
66 |
+
|
67 |
+
send_button = gr.Button(value='Transcribir')
|
|
|
|
|
68 |
transc = gr.Textbox(label='Transcripción',value='',)
|
69 |
+
|
70 |
+
button2 = gr.Button(value='Respuesta de la IA')
|
71 |
respuesta = gr.Textbox(label='Respuesta',interactive=False,value='')
|
72 |
|
73 |
send_button.click(fn=transcribe,inputs=voice,outputs=transc)
|