File size: 752 Bytes
67466fe
bdd1e35
67466fe
 
 
 
 
ab404a0
 
 
 
 
 
 
3c7ff82
ab404a0
 
 
 
67466fe
ab404a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from toxic_detection import ToxicClassifier
import speech_recognition as sr
import gradio as gr

# Create an instance of the FakeContentClassifier class
toxic_content_classifier = ToxicClassifier()

def Prediction(text,audio):
    if not text:
        r = sr.Recognizer()
        sample_rate, audio_data = audio
        audio = sr.AudioData(audio_data, sample_rate=sample_rate,sample_width=2)
        try:
            text = r.recognize_google(audio, language='ur')
            return toxic_content_classifier.predict(text)
        except:
            return "sorry could not recognize what you said"
    else:
        return toxic_content_classifier.predict(text)

gr.Interface(fn=Prediction,inputs=["text","audio"],outputs="text",share=True).launch()