File size: 1,382 Bytes
4449a5f bfa0b4d 9d7dce1 f0dfb53 2772053 f0dfb53 e1aa123 f0dfb53 e1aa123 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
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):
# # 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()
|