File size: 1,074 Bytes
285263e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109b367
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
# -*- coding: utf-8 -*-
"""GradioASRdemo.ipynb

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/drive/1OgSEOxvR1jUIG-aE0dQHXpr9-ODs63Ll
"""

import gradio as gr
from transformers import AutoFeatureExtractor, AutoModelForSeq2SeqLM, AutoTokenizer, pipeline

model_name1 = "openai/whisper-tiny"
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name1)
sampling_rate = feature_extractor.sampling_rate
asr = pipeline("automatic-speech-recognition", model=model_name1)

def speech_to_text(input_file):
    transcribed_text = asr(input_file, chunk_length_s=30)  #, chunk_length_s=30
    return transcribed_text["text"]


#inputs=gr.Audio(source="upload", type="filepath", label="Upload your audio")
inputs=gr.Audio(sources="upload", type="filepath", label="Upload Kannada audio file")
# outputs=gr.Textbox()
# examples = [["test1.wav"], ["test2.wav"]]
description = "Demo for Kannada ASR model "

gr.Interface(
    speech_to_text,
    inputs = inputs,
    outputs = "text",
    title="Kannada ASR model",
).launch()