import gradio as gr import librosa from asr import transcribe, ASR_EXAMPLES, ASR_LANGUAGES, ASR_NOTE from tts import synthesize, TTS_EXAMPLES, TTS_LANGUAGES from lid import identify, LID_EXAMPLES demo = gr.Blocks() mms_select_source_trans = gr.Radio( ["Record from Mic", "Upload audio"], label="Audio input", value="Record from Mic", ) mms_mic_source_trans = gr.Audio(source="microphone", type="filepath", label="Use mic") mms_upload_source_trans = gr.Audio( source="upload", type="filepath", label="Upload file", visible=False ) # Filter ASR_LANGUAGES to only include Faroese ASR_LANGUAGES = {'fao': 'Faroese'} mms_transcribe = gr.Interface( fn=transcribe, inputs=[ mms_select_source_trans, mms_mic_source_trans, mms_upload_source_trans, gr.Dropdown( [f"{k} ({v})" for k, v in ASR_LANGUAGES.items()], label="Mál", value="fao (Faroese)", ), # gr.Checkbox(label="Use Language Model (if available)", default=True), ], outputs="text", examples=ASR_EXAMPLES, title="Talukennari", description=( "Transcribe audio from a microphone or input file in your desired language." ), article=ASR_NOTE, allow_flagging="never", ) # Filter TTS_LANGUAGES to only include Faroese TTS_LANGUAGES = {'fao': 'Faroese'} mms_synthesize = gr.Interface( fn=synthesize, inputs=[ gr.Text(label="Tekstur at lesa upp"), gr.Dropdown( [f"{k} ({v})" for k, v in TTS_LANGUAGES.items()], label="Mál", value="fao (Faroese)", ), gr.Slider(minimum=0.1, maximum=4.0, value=1.0, step=0.1, label="Speed"), ], outputs=[ gr.Audio(label="Ljóð frá teldutaluni", type="numpy"), gr.Text(label="Filtered text after removing OOVs"), ], examples=TTS_EXAMPLES, title="Teldutala", description=("Generate audio in your desired language from input text."), allow_flagging="never", ) mms_select_source_iden = gr.Radio( ["Tak upp frá mikrofonini", "Vel ljóðfílu"], label="Audio input", value="Record from Mic", ) mms_mic_source_iden = gr.Audio(source="microphone", type="filepath", label="Use mic") mms_upload_source_iden = gr.Audio( source="upload", type="filepath", label="Upload file", visible=False ) mms_identify = gr.Interface( fn=identify, inputs=[ mms_select_source_iden, mms_mic_source_iden, mms_upload_source_iden, ], outputs=gr.Label(num_top_classes=10), examples=LID_EXAMPLES, title="Máleyðmerkjari", description=("Identity the language of input audio."), allow_flagging="never", ) tabbed_interface = gr.TabbedInterface( [mms_transcribe, mms_synthesize, mms_identify], ["Talukennari", "Teldutala", "Máleyðmerkjari"], ) with gr.Blocks() as demo: gr.Markdown( "
MMS: Scaling Speech Technology to 1000+ languages demo. See our blog post and paper.
" ) gr.HTML( """