Seidazymov Adil commited on
Commit
4fd964c
1 Parent(s): 884f987

Final 1.10

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -78,17 +78,27 @@ def detect_toxic_local(text_whisper):
78
  return None
79
 
80
 
81
- def assessment(file_path):
82
  language = detect_language(file_path) or "unknown"
83
  result_text = request_gradio(file_path, language) or ""
84
  result_emotion = detect_emotion(file_path) or "unknown"
85
  result_toxic = detect_toxic_local(result_text) or False
86
- return json.dumps({"language": language, "transcription": result_text, "emotion": result_emotion, "toxic": result_toxic,})
87
 
 
88
 
89
- gradio_app = gr.Interface(
90
- fn=assessment,
91
- inputs=gr.Audio(sources=["upload"], type="filepath"),
92
- outputs="json"
93
- )
94
- gradio_app.launch()
 
 
 
 
 
 
 
 
 
 
78
  return None
79
 
80
 
81
+ def assessment(file_path, language):
82
  language = detect_language(file_path) or "unknown"
83
  result_text = request_gradio(file_path, language) or ""
84
  result_emotion = detect_emotion(file_path) or "unknown"
85
  result_toxic = detect_toxic_local(result_text) or False
86
+ return json.dumps({"transcription": result_text, "emotion": result_emotion, "toxic": result_toxic,})
87
 
88
+ demo = gr.Blocks()
89
 
90
+ with demo:
91
+ with gr.Tabs():
92
+ with gr.TabItem('Language Detection'):
93
+ language_detection_interface = gr.Interface(
94
+ fn=detect_language,
95
+ inputs=gr.Audio(sources=["upload"], type="filepath"),
96
+ outputs='text',
97
+ )
98
+ with gr.TabItem('Toxic & Emotion Detection'):
99
+ toxic_and_emotion_detection_interface = gr.Interface(
100
+ fn=assessment,
101
+ inputs=[gr.Audio(sources=["upload"], type="filepath"), gr.Textbox(label="Language")],
102
+ outputs='json',
103
+ )
104
+ demo.launch()