Hindi_ASR / app.py
cdactvm's picture
Update app.py
62b1787 verified
raw
history blame
1.31 kB
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 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):
# # Process the audio file
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()