Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import whisper
|
4 |
-
from transformers import pipeline
|
|
|
|
|
|
|
|
|
5 |
|
6 |
model_name = "Aismantas/whisper-base-lithuanian"
|
7 |
asr_pipeline = pipeline("automatic-speech-recognition", model=model_name)
|
@@ -9,7 +13,8 @@ asr_pipeline = pipeline("automatic-speech-recognition", model=model_name)
|
|
9 |
def transcribe(filepath):
|
10 |
# Assuming the file is named 'audio.wav'
|
11 |
# Run the transcription
|
12 |
-
|
|
|
13 |
|
14 |
|
15 |
demo = gr.Interface(fn=transcribe, inputs=[gr.Audio(type='filepath')], outputs="text")
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
import whisper
|
4 |
+
from transformers import MarianMTModel, MarianTokenizer, pipeline
|
5 |
+
|
6 |
+
model_name = "Helsinki-NLP/opus-mt-tc-big-lt-en"
|
7 |
+
tokenizer = MarianTokenizer.from_pretrained(model_name)
|
8 |
+
translation_model = MarianMTModel.from_pretrained(model_name)
|
9 |
|
10 |
model_name = "Aismantas/whisper-base-lithuanian"
|
11 |
asr_pipeline = pipeline("automatic-speech-recognition", model=model_name)
|
|
|
13 |
def transcribe(filepath):
|
14 |
# Assuming the file is named 'audio.wav'
|
15 |
# Run the transcription
|
16 |
+
transcript = asr_pipeline(filepath)
|
17 |
+
return translation_model.generate(**tokenizer(transcript['text'], return_tensors="pt", padding=True))
|
18 |
|
19 |
|
20 |
demo = gr.Interface(fn=transcribe, inputs=[gr.Audio(type='filepath')], outputs="text")
|