Commit
·
a95a91f
1
Parent(s):
7620123
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import whisper
|
| 3 |
+
from langcodes import *
|
| 4 |
+
|
| 5 |
+
def speech_to_text(tmp_filename, uploaded, model_size):
|
| 6 |
+
model = whisper.load_model(model_size)
|
| 7 |
+
source = uploaded if uploaded is not None else tmp_filename
|
| 8 |
+
result = model.transcribe(source)
|
| 9 |
+
return f'Detected language: {Language.make(language=result["language"]).display_name()}\n\n You said: {result["text"]}'
|
| 10 |
+
|
| 11 |
+
gr.Interface(
|
| 12 |
+
title="",
|
| 13 |
+
thumbnail="",
|
| 14 |
+
css="""
|
| 15 |
+
footer {visibility: hidden}
|
| 16 |
+
.gr-prose p{text-align: center;}
|
| 17 |
+
.gr-button {background: black;color: white}
|
| 18 |
+
""",
|
| 19 |
+
description="",
|
| 20 |
+
fn=speech_to_text,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.Audio(source="upload", type="filepath", label="Upload Audio"),
|
| 23 |
+
gr.Dropdown(label="Select model size",value="base",choices=["tiny", "base", "small", "medium", "large"])],
|
| 24 |
+
outputs="text").launch()
|