Santiago Roman commited on
Commit
06cad47
1 Parent(s): e02a4be
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ import torch
3
+ import gradio as gr
4
+
5
+ from transformers import pipeline
6
+
7
+ pipe = pipeline(model="carlosaccardi/whisper-swedish-new")
8
+
9
+ def transcribe(audio):
10
+ text = pipe(audio)["text"]
11
+ generator = pipeline('text-generation', model = 'birgermoell/swedish-gpt')
12
+ return generator(text, max_length = 50, num_return_sequences=1)[0]['generated_text']
13
+
14
+ iface = gr.Interface(
15
+ fn=transcribe,
16
+ inputs=gr.Audio(source="microphone", type="filepath"),
17
+ outputs="text",
18
+ title="Swedish text generation",
19
+ description="Tell the API a sentence to be completed.",
20
+ )
21
+
22
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio