Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
p = pipeline("automatic-speech-recognition")
|
5 |
+
|
6 |
+
def transcribe(audio, state=""):
|
7 |
+
""" Speech to text function using pipeline"""
|
8 |
+
text = p(audio)["text"]
|
9 |
+
state += text + " "
|
10 |
+
return state, state
|
11 |
+
|
12 |
+
gr.Interface(
|
13 |
+
fn=transcribe,
|
14 |
+
inputs=[gr.inputs.Audio(source="microphone", type="filepath", label="Record/ Drop audio"), "state"],
|
15 |
+
outputs=["textbox", "state"],
|
16 |
+
title="Automatic Speech Recognition",
|
17 |
+
description="Enable the recognition spoken language into text by computers.",
|
18 |
+
theme="huggingface",
|
19 |
+
live=True).launch()
|