Seidazymov Adil commited on
Commit ·
fb7d32a
1
Parent(s): 4fd964c
Final 1.11
Browse files33 unmodified lines34353637383940414243444546474849505152535455565758596017 unmodified lines78798081828384858687888990919233 unmodified linesreturn Nonedef request_gradio(file_path, language):try:result = transcriber.predict(audio_filepath=file(file_path),task="transcribe",batch_size=24,chunk_length_s=30,sampling_rate=16000,language=language,num_speakers=2,min_speakers=2,max_speakers=2,assisted=False,api_name="/transcribe",)return resultexcept Exception as e:print(f"Transcription failed: {e}")return f"Transcription failed: {e}"def detect_emotion(audio):try:res = emotion_detector(audio)17 unmodified linesreturn Nonedef assessment(file_path, language):language = detect_language(file_path) or "unknown"result_text = request_gradio(file_path, language) or ""result_emotion = detect_emotion(file_path) or "unknown"result_toxic = detect_toxic_local(result_text) or Falsereturn json.dumps({"transcription": result_text, "emotion": result_emotion, "toxic": result_toxic,})demo = gr.Blocks()with demo:with gr.Tabs():with gr.TabItem('Language Detection'):33 unmodified lines34353637383917 unmodified lines5758596061626364656667686933 unmodified linesreturn Nonedef detect_emotion(audio):try:res = emotion_detector(audio)17 unmodified linesreturn Nonedef assessment(file_path, result_text):result_emotion = detect_emotion(file_path) or "unknown"result_toxic = detect_toxic_local(result_text) or Falsereturn json.dumps({"emotion": result_emotion, "toxic": result_toxic})demo = gr.Blocks()with demo:with gr.Tabs():with gr.TabItem('Language Detection'):
app.py+3-26