Spaces:
Runtime error
Runtime error
Commit
Β·
b037802
1
Parent(s):
ac89e80
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def main():
|
4 |
+
title = """<h1 align="center">π€ Multilingual ASR π¬</h1>"""
|
5 |
+
description = """
|
6 |
+
π» This demo showcases a general-purpose speech recognition model called Whisper. It is trained on a large dataset of diverse audio and supports multilingual speech recognition, speech translation, and language identification tasks.<br><br>
|
7 |
+
<br>
|
8 |
+
βοΈ Components of the tool:<br>
|
9 |
+
<br>
|
10 |
+
- Real-time multilingual speech recognition<br>
|
11 |
+
- Language identification<br>
|
12 |
+
- Sentiment analysis of the transcriptions<br>
|
13 |
+
<br>
|
14 |
+
π― The sentiment analysis results are provided as a dictionary with different emotions and their corresponding scores.<br>
|
15 |
+
<br>
|
16 |
+
π The sentiment analysis results are displayed with emojis representing the corresponding sentiment.<br>
|
17 |
+
<br>
|
18 |
+
β
The higher the score for a specific emotion, the stronger the presence of that emotion in the transcribed text.<br>
|
19 |
+
<br>
|
20 |
+
β Use the microphone for real-time speech recognition.<br>
|
21 |
+
<br>
|
22 |
+
β‘οΈ The model will transcribe the audio and perform sentiment analysis on the transcribed text.<br>
|
23 |
+
"""
|
24 |
+
|
25 |
+
custom_css = """
|
26 |
+
#banner-image {
|
27 |
+
display: block;
|
28 |
+
margin-left: auto;
|
29 |
+
margin-right: auto;
|
30 |
+
}
|
31 |
+
#chat-message {
|
32 |
+
font-size: 14px;
|
33 |
+
min-height: 300px;
|
34 |
+
}
|
35 |
+
"""
|
36 |
+
|
37 |
+
block = gr.Blocks(css=custom_css)
|
38 |
+
|
39 |
+
with block:
|
40 |
+
gr.HTML(title)
|
41 |
+
|
42 |
+
with gr.Row():
|
43 |
+
with gr.Column():
|
44 |
+
gr.HTML(description)
|
45 |
+
|
46 |
+
with gr.Group():
|
47 |
+
with gr.Box():
|
48 |
+
audio = gr.Audio(
|
49 |
+
label="Input Audio",
|
50 |
+
show_label=False,
|
51 |
+
source="microphone",
|
52 |
+
type="filepath"
|
53 |
+
)
|
54 |
+
|
55 |
+
sentiment_option = gr.Radio(
|
56 |
+
choices=["Sentiment Only", "Sentiment + Score"],
|
57 |
+
label="Select an option",
|
58 |
+
default="Sentiment Only"
|
59 |
+
)
|
60 |
+
|
61 |
+
btn = gr.Button("Transcribe")
|
62 |
+
|
63 |
+
lang_str = gr.Textbox(label="Language")
|
64 |
+
|
65 |
+
text = gr.Textbox(label="Transcription")
|
66 |
+
|
67 |
+
sentiment_output = gr.Textbox(label="Sentiment Analysis Results", output=True)
|
68 |
+
|
69 |
+
prediction = gr.Textbox(label="Prediction")
|
70 |
+
|
71 |
+
language_translation = gr.Textbox(label="Language Translation")
|
72 |
+
|
73 |
+
|
74 |
+
btn.click(inference, inputs=[audio, sentiment_option], outputs=[lang_str, text, sentiment_output, prediction,language_translation])
|
75 |
+
|
76 |
+
# gr.HTML('''
|
77 |
+
# <div class="footer">
|
78 |
+
# <p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a>
|
79 |
+
# </p>
|
80 |
+
# </div>
|
81 |
+
# ''')
|
82 |
+
|
83 |
+
block.launch()
|