Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
| 3 |
-
import pyttsx3
|
| 4 |
|
| 5 |
-
# Somali
|
| 6 |
-
tts_engine = pyttsx3.init()
|
| 7 |
-
tts_engine.setProperty('rate', 150)
|
| 8 |
-
tts_engine.setProperty('voice', 'english') # Somali voice not supported, but neutral voice used
|
| 9 |
-
|
| 10 |
-
# Sample responses for intents
|
| 11 |
sample_responses = {
|
| 12 |
"greet": ["Waad salaaman tahay!", "Nabad baa!"],
|
| 13 |
"goodbye": ["Nabad gelyo!", "Ilaahay ku nabad yeelo!"],
|
|
@@ -15,7 +9,7 @@ sample_responses = {
|
|
| 15 |
"default": ["Waan ka xumahay, ma fahmin su'aashaada."]
|
| 16 |
}
|
| 17 |
|
| 18 |
-
# Simple keyword
|
| 19 |
def classify_intent(message):
|
| 20 |
message = message.lower()
|
| 21 |
if "iska warran" in message or "nabad" in message or "subax" in message:
|
|
@@ -31,18 +25,15 @@ def classify_intent(message):
|
|
| 31 |
def chat(message):
|
| 32 |
intent = classify_intent(message)
|
| 33 |
reply = random.choice(sample_responses[intent])
|
| 34 |
-
return reply
|
| 35 |
|
| 36 |
-
# Gradio
|
| 37 |
iface = gr.Interface(
|
| 38 |
fn=chat,
|
| 39 |
inputs=gr.Textbox(lines=2, placeholder="Weydii su’aashaada halkan..."),
|
| 40 |
-
outputs=
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
],
|
| 44 |
-
title="Somali Rasa Bot (Offline Demo)",
|
| 45 |
-
description="Text + voice bot using Somali intents. No backend required."
|
| 46 |
)
|
| 47 |
|
| 48 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import random
|
|
|
|
| 3 |
|
| 4 |
+
# Somali intent responses
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
sample_responses = {
|
| 6 |
"greet": ["Waad salaaman tahay!", "Nabad baa!"],
|
| 7 |
"goodbye": ["Nabad gelyo!", "Ilaahay ku nabad yeelo!"],
|
|
|
|
| 9 |
"default": ["Waan ka xumahay, ma fahmin su'aashaada."]
|
| 10 |
}
|
| 11 |
|
| 12 |
+
# Simple keyword intent classification
|
| 13 |
def classify_intent(message):
|
| 14 |
message = message.lower()
|
| 15 |
if "iska warran" in message or "nabad" in message or "subax" in message:
|
|
|
|
| 25 |
def chat(message):
|
| 26 |
intent = classify_intent(message)
|
| 27 |
reply = random.choice(sample_responses[intent])
|
| 28 |
+
return reply
|
| 29 |
|
| 30 |
+
# Gradio interface
|
| 31 |
iface = gr.Interface(
|
| 32 |
fn=chat,
|
| 33 |
inputs=gr.Textbox(lines=2, placeholder="Weydii su’aashaada halkan..."),
|
| 34 |
+
outputs="text",
|
| 35 |
+
title="Somali Rasa Bot (Text Only)",
|
| 36 |
+
description="Ku hadal Somali oo hel jawaab degdeg ah. No backend required."
|
|
|
|
|
|
|
|
|
|
| 37 |
)
|
| 38 |
|
| 39 |
iface.launch()
|