File size: 2,925 Bytes
6e96e33
 
608a609
 
 
 
 
 
92ca42f
608a609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e96e33
 
608a609
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
license: mit
title: Ibi-Voice Translation Backend
sdk: gradio
emoji: 🌍
colorFrom: blue
colorTo: pink
short_description: JR Digital Insights - Professional English to Ibibio transla
sdk_version: 5.35.0
---
# 🎯 Ibi-Voice Translation Backend

**JR Digital Insights** - AI-powered Ibibio translation service on Hugging Face Spaces

## πŸš€ Quick Setup

### 1. Get Your API Keys

#### Groq API Key (Free)
1. Go to [console.groq.com](https://console.groq.com)
2. Sign up/login
3. Navigate to "API Keys"
4. Create new key
5. Copy the key (starts with `gsk_...`)

#### Tavily Search API Key (Free Tier)
1. Go to [tavily.com](https://tavily.com)
2. Sign up for free account
3. Get your API key from dashboard
4. Copy the key (starts with `tvly-...`)

### 2. Configure Hugging Face Space

1. In your HF Space, click **"Settings"** tab
2. Scroll to **"Repository secrets"**
3. Add these secrets:
   ```
   Name: GROQ_API_KEY
   Value: your_groq_key_here
   
   Name: TAVILY_API_KEY  
   Value: your_tavily_key_here
   ```
4. Click **"Add secret"** for each

### 3. Upload Files

Upload these files to your HF Space:
- `app.py` (main backend code)
- `requirements.txt` (dependencies)
- `README.md` (this file)

## 🌐 API Usage

### Frontend Integration

```javascript
// Connect your Ibi-Voice frontend to this backend
async function translateOnline(query) {
    const response = await fetch('https://your-username-ibi-voice-backend.hf.space/api/predict', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({
            data: [query],
            fn_index: 0  // First function in Gradio interface
        })
    });
    
    const result = await response.json();
    return result.data[0];
}

// Usage example
translateOnline("What is 'God is good' in Ibibio?")
    .then(translation => console.log(translation));
```

### Direct API Call

```bash
curl -X POST "https://your-username-ibi-voice-backend.hf.space/api/predict" \
     -H "Content-Type: application/json" \
     -d '{
       "data": ["What is God is good in Ibibio?"],
       "fn_index": 0
     }'
```

## πŸ”§ Features

- **🧠 AI Reasoning**: Uses Groq LLaMA3-8B for intelligent translation analysis
- **πŸ” Web Search**: Real-time lookup via Tavily API for current information
- **πŸ“š Local Dictionary**: Built-in fallback for common Ibibio phrases
- **🎯 Smart Combining**: Merges all sources for best possible translation

## πŸ“‹ Testing Queries

Try these example queries:
- "What is 'God is good' in Ibibio?"
- "How do you say 'thank you' in Ibibio?"
- "Translate 'good morning' to Ibibio"
- "What does 'sosongo' mean in English?"

## 🎯 Next Steps

1. Deploy this backend to HF Spaces
2. Test the API endpoints
3. Integrate with your Ibi-Voice React frontend
4. Add more local dictionary entries as needed

---

**Built for JR Digital Insights** | Ibibio Language Preservation Project