Seidazymov Adil commited on
Commit ·
4f92cf0
1
Parent(s): de86ddb
Detect language
Browse files123456789101112131415161718# import gradio as gr# from transformers import pipeline# pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")# def predict(input_img):# predictions = pipeline(input_img)# return input_img, {p["label"]: p["score"] for p in predictions}# gradio_app = gr.Interface(# predict,# inputs=gr.Image(label="Select hot dog candidate", sources=['upload', 'webcam'], type="pil"),# outputs=[gr.Image(label="Processed Image"), gr.Label(label="Result", num_top_classes=2)],# title="Hot Dog? Or Not?",# )# if __name__ == "__main__":# gradio_app.launch()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556import gradio as grfrom transformers import pipelinefrom gradio_client import Client, filedef detect_language(file_path):client = Client("adrien-alloreview/speechbrain-lang-id-voxlingua107-ecapa")result = client.predict(param_0=file(file_path), api_name="/predict")language_result = result["label"].split(": ")[1]if language_result.lower() in ["russian", "belarussian", "ukrainian"]:selected_language = "russian"else:selected_language = "kazakh"return selected_language# def detect_emotion(audio):# pipe = pipeline(# "audio-classification",# model="HowMannyMore/wav2vec2-lg-xlsr-ur-speech-emotion-recognition",# )# res = pipe(audio)# emotion_with_max_score = res[0]["label"]## return emotion_with_max_score### def detect_toxic_local(text_whisper):# model_name_rus = "IlyaGusev/rubertconv_toxic_clf"# pipe = pipeline(# "text-classification",# model=model_name_rus,# tokenizer=model_name_rus,# framework="pt",# max_length=512,# truncation=True,# device=0,# )# res = pipe([text_whisper])[0]["label"]# if res == "toxic":# return True# if res == "neutral":# return False# else:# return Nonegradio_app = gr.Interface(fn=detect_language,inputs=gr.Audio(source="upload", type="filepath"),outputs="text",title="File Upload Transcription",description="Upload an audio file to determine language.")if __name__ == "__main__":gradio_app.launch()
app.py+52-14