from transformers import pipeline import gradio as gr import os import deepl import openai TARGET_LANG = "EN-GB" deepl_key = os.environ.get('DEEPL') translator = deepl.Translator(deepl_key) pipe = pipeline(model="torileatherman/train_first_try") # change to "your-username/the-name-you-picked" def transcribe(audio): text_sv = pipe(audio)["text"] print(f"Audio transcribed: {text_sv}") text_en = translator.translate_text(text_sv, target_lang=TARGET_LANG).text print(f"Text translated: {text_en}") return text_sv, text_en iface = gr.Interface( fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs=[gr.Textbox(label="Transcribed text"), gr.Textbox(label="English translation")], title="Swedish speech to english text", description="Transcribing swedish speech to text and translating to english!", ) iface.launch()