shethjenil's picture
Upload 6 files
73208f7 verified
from utils_trans import IndicTrans
from utils_indic_seamless import INDIC_SEAMLESS
from json import load as json_load
from torch import device as Device
from torch.cuda import is_available as cuda_is_available
device = Device("cuda" if cuda_is_available() else "cpu")
indictrans_model = IndicTrans(json_load(open("indictrans_conf.json")),"prajdabre/rotary-indictrans2-en-indic-dist-200M","prajdabre/rotary-indictrans2-indic-en-dist-200M","ai4bharat/indictrans2-indic-indic-dist-320M")
indic_seamless_model = INDIC_SEAMLESS(json_load(open("indic_seamless_lang_conf.json")),"shethjenil/INDIC_SEAMLESS",device)
import gradio as gr
gr.TabbedInterface([gr.Interface(indictrans_model.translate,[gr.Textbox(label="Input Text"),gr.Dropdown(indictrans_model.all_lang, label="Source Language"),gr.Dropdown(indictrans_model.all_lang, label="Target Language"),],gr.Textbox(label="Result"),),gr.Interface(lambda files, lang: indic_seamless_model.speech2translate([i.name for i in files], lang),[gr.File(file_types=["audio"],label="Upload Audio Files",file_count="multiple",),gr.Dropdown(list(indic_seamless_model.lang_conf.keys()), label="Target Language"),],gr.List(label="Translations"),title="Audio Translation",),],["Indic Translation","Indic Audio Translation",],).launch()