faizeeb commited on
Commit
781a081
·
1 Parent(s): 674cb68

Update app.py

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