Seidazymov Adil
commited on
Commit
•
fb7d32a
1
Parent(s):
4fd964c
Final 1.11
Browse files
app.py
CHANGED
@@ -34,27 +34,6 @@ def detect_language(file_path):
|
|
34 |
return None
|
35 |
|
36 |
|
37 |
-
def request_gradio(file_path, language):
|
38 |
-
try:
|
39 |
-
result = transcriber.predict(
|
40 |
-
audio_filepath=file(file_path),
|
41 |
-
task="transcribe",
|
42 |
-
batch_size=24,
|
43 |
-
chunk_length_s=30,
|
44 |
-
sampling_rate=16000,
|
45 |
-
language=language,
|
46 |
-
num_speakers=2,
|
47 |
-
min_speakers=2,
|
48 |
-
max_speakers=2,
|
49 |
-
assisted=False,
|
50 |
-
api_name="/transcribe",
|
51 |
-
)
|
52 |
-
return result
|
53 |
-
except Exception as e:
|
54 |
-
print(f"Transcription failed: {e}")
|
55 |
-
return f"Transcription failed: {e}"
|
56 |
-
|
57 |
-
|
58 |
def detect_emotion(audio):
|
59 |
try:
|
60 |
res = emotion_detector(audio)
|
@@ -78,15 +57,13 @@ def detect_toxic_local(text_whisper):
|
|
78 |
return None
|
79 |
|
80 |
|
81 |
-
def assessment(file_path,
|
82 |
-
language = detect_language(file_path) or "unknown"
|
83 |
-
result_text = request_gradio(file_path, language) or ""
|
84 |
result_emotion = detect_emotion(file_path) or "unknown"
|
85 |
result_toxic = detect_toxic_local(result_text) or False
|
86 |
-
return json.dumps({"
|
87 |
|
88 |
-
demo = gr.Blocks()
|
89 |
|
|
|
90 |
with demo:
|
91 |
with gr.Tabs():
|
92 |
with gr.TabItem('Language Detection'):
|
|
|
34 |
return None
|
35 |
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
def detect_emotion(audio):
|
38 |
try:
|
39 |
res = emotion_detector(audio)
|
|
|
57 |
return None
|
58 |
|
59 |
|
60 |
+
def assessment(file_path, result_text):
|
|
|
|
|
61 |
result_emotion = detect_emotion(file_path) or "unknown"
|
62 |
result_toxic = detect_toxic_local(result_text) or False
|
63 |
+
return json.dumps({"emotion": result_emotion, "toxic": result_toxic})
|
64 |
|
|
|
65 |
|
66 |
+
demo = gr.Blocks()
|
67 |
with demo:
|
68 |
with gr.Tabs():
|
69 |
with gr.TabItem('Language Detection'):
|