|
import warnings |
|
warnings.filterwarnings("ignore") |
|
import os |
|
import re |
|
import gradio as gr |
|
import numpy as np |
|
import torchaudio |
|
import nbimporter |
|
from transformers import pipeline |
|
from transformers import AutoProcessor |
|
from pyctcdecode import build_ctcdecoder |
|
from transformers import Wav2Vec2ProcessorWithLM |
|
from text2int import text_to_int |
|
from isNumber import is_number |
|
from Text2List import text_to_list |
|
from convert2list import convert_to_list |
|
from processDoubles import process_doubles |
|
from replaceWords import replace_words |
|
|
|
transcriber = pipeline(task="automatic-speech-recognition", model="cdactvm/w2v-bert-2.0-hindi_v1") |
|
|
|
|
|
def transcribe(audio): |
|
|
|
transcript = transcriber(audio) |
|
text_value = transcript['text'] |
|
processd_doubles=process_doubles(text_value) |
|
replaced_words = replace_words(processd_doubles) |
|
converted_text=text_to_int(replaced_words) |
|
return converted_text |
|
|
|
demo=gr.Interface( |
|
transcribe, |
|
inputs=[ |
|
gr.Audio(sources=["microphone","upload"], type="filepath"), |
|
], |
|
outputs=[ |
|
"textbox" |
|
], |
|
title="Automatic Speech Recognition", |
|
description = "Demo for Automatic Speech Recognition. Use microphone to record speech. Please press Record button. Initially it will take some time to load the model. The recognized text will appear in the output textbox", |
|
).launch() |
|
|