faizeeb commited on
Commit
ab404a0
·
1 Parent(s): a6aea75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -4,7 +4,17 @@ import gradio as gr
4
  # Create an instance of the FakeContentClassifier class
5
  toxic_content_classifier = ToxicClassifier()
6
 
7
- def Prediction(text):
8
- return toxic_content_classifier.predict(text)
 
 
 
 
 
 
 
 
 
 
9
 
10
- gr.Interface(fn=Prediction,inputs="text",outputs="text",share=True).launch()
 
4
  # Create an instance of the FakeContentClassifier class
5
  toxic_content_classifier = ToxicClassifier()
6
 
7
+ def Prediction(text,audio):
8
+ if not text:
9
+ r = sr.Recognizer()
10
+ sample_rate, audio_data = audio
11
+ audio = sr.AudioData(audio_data, sample_rate=sample_rate,sample_width=2)
12
+ try:
13
+ text = r.recognize_google(audio, language='ur')
14
+ return fake_content_classifier.predict(text)
15
+ except:
16
+ return "sorry could not recognize what you said"
17
+ else:
18
+ return toxic_content_classifier.predict(text)
19
 
20
+ gr.Interface(fn=Prediction,inputs=["text","audio"],outputs="text",share=True).launch()