Spaces:
Runtime error
Runtime error
Commit
Β·
3a28669
1
Parent(s):
a5ecba4
Update app.py
Browse files
app.py
CHANGED
|
@@ -182,88 +182,85 @@ def inference(audio, sentiment_option):
|
|
| 182 |
return lang.upper(), result.text, sentiment_output, prediction[0], prediction[1]
|
| 183 |
|
| 184 |
|
| 185 |
-
def main():
|
| 186 |
-
title = """<h1 align="center">π€ Multilingual ASR π¬</h1>"""
|
| 187 |
-
description = """
|
| 188 |
-
π» 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>
|
| 189 |
-
<br>
|
| 190 |
-
βοΈ Components of the tool:<br>
|
| 191 |
-
<br>
|
| 192 |
-
- Real-time multilingual speech recognition<br>
|
| 193 |
-
- Language identification<br>
|
| 194 |
-
- Sentiment analysis of the transcriptions<br>
|
| 195 |
-
<br>
|
| 196 |
-
π― The sentiment analysis results are provided as a dictionary with different emotions and their corresponding scores.<br>
|
| 197 |
-
<br>
|
| 198 |
-
π The sentiment analysis results are displayed with emojis representing the corresponding sentiment.<br>
|
| 199 |
-
<br>
|
| 200 |
-
β
The higher the score for a specific emotion, the stronger the presence of that emotion in the transcribed text.<br>
|
| 201 |
-
<br>
|
| 202 |
-
β Use the microphone for real-time speech recognition.<br>
|
| 203 |
-
<br>
|
| 204 |
-
β‘οΈ The model will transcribe the audio and perform sentiment analysis on the transcribed text.<br>
|
| 205 |
-
"""
|
| 206 |
-
|
| 207 |
-
custom_css = """
|
| 208 |
-
#banner-image {
|
| 209 |
-
display: block;
|
| 210 |
-
margin-left: auto;
|
| 211 |
-
margin-right: auto;
|
| 212 |
-
}
|
| 213 |
-
#chat-message {
|
| 214 |
-
font-size: 14px;
|
| 215 |
-
min-height: 300px;
|
| 216 |
-
}
|
| 217 |
-
"""
|
| 218 |
-
|
| 219 |
-
block = gr.Blocks(css=custom_css)
|
| 220 |
-
|
| 221 |
-
with block:
|
| 222 |
-
gr.HTML(title)
|
| 223 |
-
|
| 224 |
-
with gr.Row():
|
| 225 |
-
with gr.Column():
|
| 226 |
-
gr.HTML(description)
|
| 227 |
-
|
| 228 |
-
with gr.Group():
|
| 229 |
-
with gr.Box():
|
| 230 |
-
|
| 231 |
-
audio = gr.Audio(
|
| 232 |
-
label="Input Audio",
|
| 233 |
-
show_label=False,
|
| 234 |
-
source="microphone",
|
| 235 |
-
type="filepath"
|
| 236 |
-
)
|
| 237 |
-
|
| 238 |
-
sentiment_option = gr.Radio(
|
| 239 |
-
choices=["Sentiment Only", "Sentiment + Score"],
|
| 240 |
-
label="Select an option",
|
| 241 |
-
default="Sentiment Only"
|
| 242 |
-
)
|
| 243 |
-
|
| 244 |
-
btn = gr.Button("Transcribe")
|
| 245 |
-
|
| 246 |
-
lang_str = gr.Textbox(label="Language")
|
| 247 |
-
|
| 248 |
-
text = gr.Textbox(label="Transcription")
|
| 249 |
-
|
| 250 |
-
sentiment_output = gr.Textbox(label="Sentiment Analysis Results", output=True)
|
| 251 |
-
|
| 252 |
-
prediction = gr.Textbox(label="Prediction")
|
| 253 |
-
|
| 254 |
-
language_translation = gr.Textbox(label="Language Translation")
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
btn.click(inference, inputs=[audio, sentiment_option], outputs=[lang_str, text, sentiment_output, prediction,language_translation])
|
| 258 |
-
|
| 259 |
-
# gr.HTML('''
|
| 260 |
-
# <div class="footer">
|
| 261 |
-
# <p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a>
|
| 262 |
-
# </p>
|
| 263 |
-
# </div>
|
| 264 |
-
# ''')
|
| 265 |
-
|
| 266 |
-
block.launch()
|
| 267 |
-
|
| 268 |
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
return lang.upper(), result.text, sentiment_output, prediction[0], prediction[1]
|
| 183 |
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
|
| 186 |
+
title = """<h1 align="center">π€ Multilingual ASR π¬</h1>"""
|
| 187 |
+
description = """
|
| 188 |
+
π» 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>
|
| 189 |
+
<br>
|
| 190 |
+
βοΈ Components of the tool:<br>
|
| 191 |
+
<br>
|
| 192 |
+
- Real-time multilingual speech recognition<br>
|
| 193 |
+
- Language identification<br>
|
| 194 |
+
- Sentiment analysis of the transcriptions<br>
|
| 195 |
+
<br>
|
| 196 |
+
π― The sentiment analysis results are provided as a dictionary with different emotions and their corresponding scores.<br>
|
| 197 |
+
<br>
|
| 198 |
+
π The sentiment analysis results are displayed with emojis representing the corresponding sentiment.<br>
|
| 199 |
+
<br>
|
| 200 |
+
β
The higher the score for a specific emotion, the stronger the presence of that emotion in the transcribed text.<br>
|
| 201 |
+
<br>
|
| 202 |
+
β Use the microphone for real-time speech recognition.<br>
|
| 203 |
+
<br>
|
| 204 |
+
β‘οΈ The model will transcribe the audio and perform sentiment analysis on the transcribed text.<br>
|
| 205 |
+
"""
|
| 206 |
+
|
| 207 |
+
custom_css = """
|
| 208 |
+
#banner-image {
|
| 209 |
+
display: block;
|
| 210 |
+
margin-left: auto;
|
| 211 |
+
margin-right: auto;
|
| 212 |
+
}
|
| 213 |
+
#chat-message {
|
| 214 |
+
font-size: 14px;
|
| 215 |
+
min-height: 300px;
|
| 216 |
+
}
|
| 217 |
+
"""
|
| 218 |
+
|
| 219 |
+
block = gr.Blocks(css=custom_css)
|
| 220 |
+
|
| 221 |
+
with block:
|
| 222 |
+
gr.HTML(title)
|
| 223 |
+
|
| 224 |
+
with gr.Row():
|
| 225 |
+
with gr.Column():
|
| 226 |
+
gr.HTML(description)
|
| 227 |
+
|
| 228 |
+
with gr.Group():
|
| 229 |
+
with gr.Box():
|
| 230 |
+
|
| 231 |
+
audio = gr.Audio(
|
| 232 |
+
label="Input Audio",
|
| 233 |
+
show_label=False,
|
| 234 |
+
source="microphone",
|
| 235 |
+
type="filepath"
|
| 236 |
+
)
|
| 237 |
+
|
| 238 |
+
sentiment_option = gr.Radio(
|
| 239 |
+
choices=["Sentiment Only", "Sentiment + Score"],
|
| 240 |
+
label="Select an option",
|
| 241 |
+
default="Sentiment Only"
|
| 242 |
+
)
|
| 243 |
+
|
| 244 |
+
btn = gr.Button("Transcribe")
|
| 245 |
+
|
| 246 |
+
lang_str = gr.Textbox(label="Language")
|
| 247 |
+
|
| 248 |
+
text = gr.Textbox(label="Transcription")
|
| 249 |
+
|
| 250 |
+
sentiment_output = gr.Textbox(label="Sentiment Analysis Results", output=True)
|
| 251 |
+
|
| 252 |
+
prediction = gr.Textbox(label="Prediction")
|
| 253 |
+
|
| 254 |
+
language_translation = gr.Textbox(label="Language Translation")
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
btn.click(inference, inputs=[audio, sentiment_option], outputs=[lang_str, text, sentiment_output, prediction,language_translation])
|
| 258 |
+
|
| 259 |
+
# gr.HTML('''
|
| 260 |
+
# <div class="footer">
|
| 261 |
+
# <p>Model by <a href="https://github.com/openai/whisper" style="text-decoration: underline;" target="_blank">OpenAI</a>
|
| 262 |
+
# </p>
|
| 263 |
+
# </div>
|
| 264 |
+
# ''')
|
| 265 |
+
|
| 266 |
+
block.launch()
|