|
import nemo.collections.asr as nemo_asr |
|
import gradio as gr |
|
import pandas as pd |
|
|
|
asr_model = nemo_asr.models.EncDecCTCModelBPE.from_pretrained(model_name="stt_rw_conformer_ctc_large") |
|
df = pd.read_csv("amasaku_data.tsv",sep='\t') |
|
print(df) |
|
amasaku_mapping = {str(key).lower():str(val).lower() for key,val in zip(df.iloc[:,0],df.iloc[:,1])} |
|
|
|
def transcribe(file): |
|
|
|
|
|
|
|
|
|
print("filename: ",file) |
|
transcription= asr_model.transcribe([file]) |
|
transcription = transcription[0].lower().split() |
|
transcribed_with_amasuku = [] |
|
for word in transcription: |
|
transcribed_with_amasuku.append(amasaku_mapping.get(word,word)) |
|
transcribed_with_amasuku = " ".join(transcribed_with_amasuku) |
|
return transcribed_with_amasaku.capitalize() |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
uploaded_audio = gr.Audio(label="Upload Audio File", type="filepath") |
|
|
|
with gr.Column(): |
|
transcription = gr.Textbox(type="text", label="Transcription") |
|
with gr.Row(): |
|
transcribe_button = gr.Button("Transcribe") |
|
|
|
transcribe_button.click( |
|
transcribe, |
|
[uploaded_audio], |
|
transcription |
|
) |
|
|
|
|
|
demo.launch() |