Spaces:
Build error
Build error
Download app.py from faizeeb/Toxic_content_detection: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/faizeeb/Toxic_content_detection/resolve/main/app.py
- Command line
-
hf download hf://spaces/faizeeb/Toxic_content_detection/app.py
-
curl -L -o app.py https://huggingface.co/spaces/faizeeb/Toxic_content_detection/resolve/main/app.py
752 Bytes
| 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() |