Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rafiki

A voice assistant that takes its commands in Kiswahili.

Rafiki means friend. You say its name to wake it, then talk to it in Swahili:

rafiki                    →  wakes up and listens
fungua spotify            →  opens Spotify
fungua visual studio      →  opens VS Code
niko wapi                 →  reverse-geocodes your location and says it aloud
saa                       →  tells you the time
mzaha                     →  tells you a joke
nani alikutengeneza       →  "who made you?"

fungua is "open", and it fronts about twenty applications — browser, calculator, file explorer, Notepad, PyCharm, Android Studio, WhatsApp, Telegram, Discord, Instagram, Twitter, TikTok, Facebook, the camera, Oracle VM, Epic Games, Binance.

Roughly 650 lines of Python and a Chrome extension, written in 2023.

Why Kiswahili

Almost every voice assistant assumes you speak English. Alexa, Siri and Google Assistant have never supported Swahili, a language with somewhere around 200 million speakers across East Africa.

This was an attempt at one that does — where the wake word, the verbs and the questions are all in the language people around it actually use, rather than an English assistant with a translation layer bolted on the front.

How it is put together

Two halves that talk to each other:

main.py — the assistant itself. Listens on the microphone through speech_recognition, detects the language, and answers with pyttsx3 or gTTS. Everything the desktop can do happens here: opening applications, reading the clock, geocoding your position with geopy, taking dictated notes, setting reminders, alarms and timers, sending email over SMTP, arithmetic, and music recommendations by mood.

The Chrome extensionbackground.js and content script.js, passing messages over chrome.runtime. This is the half that reaches things the desktop process cannot: composing an email in a webmail tab, starting a track, pulling directions, creating a calendar event.

Integrations along the way: OpenAI, Google APIs, Spotify, Twilio, AWS, OpenWeatherMap, googletrans, spaCy, and Hugging Face transformers.

Running it

pip install -r requirements.txt      # see the imports at the top of main.py
python main.py

The extension loads unpacked from chrome://extensions with developer mode on.

You will need your own credentials for whichever integrations you want — OpenAI, Spotify, Twilio, Google, AWS. Anything without a key stays quiet rather than crashing the assistant.

Honest notes

This was written in 2023 and it shows in a few places. Worth knowing before you read the code:

The manifest is version 2. Chrome has moved to Manifest V3, so the extension half needs porting — background.scripts becomes a service worker, and webRequestBlocking no longer exists.

The permissions list is far too wide. It asks for <all_urls>, history, cookies, contacts, downloads and system access, and the code does not use most of them. A real release would cut that to what is actually called.

The command dispatch is one long elif chain. Fine at twenty commands and unpleasant at fifty — a lookup table keyed on the verb would be the honest rewrite.

There are no tests. That is the largest gap, and the thing I would fix first if this were revived. Language detection and command matching are both plain functions over strings, which makes them the easiest possible things to test.

Why it is here

It is left as written rather than tidied up. The part worth looking at is not the code quality — it is that a Swahili-first interface was the starting point rather than a translation added afterwards, and that decision runs all the way through the command vocabulary.

License

No licence file. All rights reserved by default; ask if you want to use it.

About

A voice assistant that takes its commands in Kiswahili - fungua, saa, niko wapi. Python desktop half plus a Chrome extension

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages