Spaces:
Sleeping
Sleeping
File size: 1,177 Bytes
98c332d d5b67d3 98c332d 84128fc 98c332d 84128fc 98c332d 9d0b85b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import gradio as gr
from transformers import pipeline
# Load the Automatic Speech Recognition (ASR) model for Finnish
# asr_model = pipeline("automatic-speech-recognition", model="openai/whisper-small")
asr_model = pipeline("automatic-speech-recognition", model="Finnish-NLP/wav2vec2-base-fi-voxpopuli-v2-finetuned")
# Load the translation model for Finnish to English
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-fi-en")
# Function to handle translation from Finnish speech to English text
def translate_speech(audio):
# Convert Finnish speech to Finnish text
finnish_text = asr_model(audio)["text"]
# Translate Finnish text to English text
english_text = translator(finnish_text)[0]["translation_text"]
return english_text
# Build Gradio Interface
interface = gr.Interface(
fn=translate_speech,
inputs=gr.Audio(type="filepath"), # Remove the 'source' argument
outputs="text",
title="Finnish to English Speech Translator",
description="This app translates Finnish speech to English text. You can upload an audio file, and see the translation appear in English!"
)
# Launch the app
interface.launch(share=True)
|