Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""GradioASRdemo.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colab.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1OgSEOxvR1jUIG-aE0dQHXpr9-ODs63Ll
|
8 |
+
"""
|
9 |
+
|
10 |
+
import gradio as gr
|
11 |
+
import librosa
|
12 |
+
from transformers import AutoFeatureExtractor, AutoModelForSeq2SeqLM, AutoTokenizer, pipeline
|
13 |
+
|
14 |
+
model_name1 = "openai/whisper-tiny"
|
15 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name1)
|
16 |
+
sampling_rate = feature_extractor.sampling_rate
|
17 |
+
asr = pipeline("automatic-speech-recognition", model=model_name1)
|
18 |
+
|
19 |
+
def speech_to_text(input_file):
|
20 |
+
transcribed_text = asr(input_file, chunk_length_s=30) #, chunk_length_s=30
|
21 |
+
return transcribed_text["text"]
|
22 |
+
|
23 |
+
|
24 |
+
#inputs=gr.Audio(source="upload", type="filepath", label="Upload your audio")
|
25 |
+
inputs=gr.Audio(sources="upload", type="filepath", label="Upload Kannada audio file")
|
26 |
+
# outputs=gr.Textbox()
|
27 |
+
# examples = [["test1.wav"], ["test2.wav"]]
|
28 |
+
description = "Demo for Kannada ASR model "
|
29 |
+
|
30 |
+
gr.Interface(
|
31 |
+
speech_to_text,
|
32 |
+
inputs = inputs,
|
33 |
+
outputs = "text",
|
34 |
+
title="Kannada ASR model",
|
35 |
+
).launch()
|
36 |
+
# debug=True
|