Skip to content

Commit

Permalink
Start fixinng plugins and getting server running
Browse files Browse the repository at this point in the history
  • Loading branch information
Akul2010 committed Jul 30, 2023
1 parent 53843ec commit a6e6077
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 50 deletions.
14 changes: 8 additions & 6 deletions akulai/akulai.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import vosk
import sys
from fastapi import FastAPI
import webbrowser
import time


class JSPlugin:
Expand Down Expand Up @@ -132,12 +132,17 @@ def stop(self):
akulai = AkulAI()

if __name__ == '__main__':

# Run API server
os.system("uvicorn akulai:app --reload")
time.sleep(5)

# Create the listening thread
akulai.stop_listening = threading.Event()
akulai.listening_thread = threading.Thread(target=akulai.listen)
akulai.listening_thread.start()

@app.get("/speak/{text}")
@app.post("/speak/{text}")
async def speak(text: str):
akulai.speak(text)
return {"message": "Text synthesized"}
Expand All @@ -146,8 +151,5 @@ async def speak(text: str):
async def listen():
akulai.listen()
return {"message": "Listening..."}

# Run the server for the API
os.system("uvicorn akulai:app --reload")
webbrowser.open("http://127.0.0.1:8000")

akulai.speak("Hello, I am AkulAI. How can I help you today?")
4 changes: 2 additions & 2 deletions docs/create_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Next, create a file in your sub-directory called `plugin.info`. It should look s
```
author: John Doe
dependencies: requests, pandas
description: Lorem ipsum di olor nulla quis lorem ut libero malesuada feugiat. This plugin.info file is an example. See the akulai_plugins repository for more examples.
description: Lorem ipsum di olor nulla quis lorem ut libero malesuada feugiat. This plugin.info file is an example.
```

The dependencies may vary based on your project. Note that when listing the dependencies, list them by the name you installed them. For example, if you installed a dependency with `pip install py-example`(note that this is an example, and applies to all languages), but imported it with `import example`, you would still list the dependency `as py-example`. If you have no dependencies required to be installed, just leave it blank.
Expand All @@ -30,7 +30,7 @@ import requests
response = requests.get('http://127.0.0.1:8000/speak')
def handle(command):
if "hello" in command:
speak("Hello there!")
response.speak("Hello there!")
```
## Javascript Plugins
JavaScript plugins should read from the commandline and write to stdout using console.log().
Expand Down
4 changes: 3 additions & 1 deletion plugins/calendar/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const fs = require("fs");
const events = [];

fetch('http://127.0.0.1:8000/speak')

const addEvent = (event, date) => {
events.push({event, date});
fs.writeFileSync("events.json", JSON.stringify(events));
Expand All @@ -14,7 +16,7 @@ const checkEvents = () => {
const eventDate = new Date(event.date);
if (now.getTime() >= eventDate.getTime()) {
console.log("Reminder: " + event.event);
akulAI.speak("Reminder: " + event.event);
speak("Reminder: " + event.event);
}
});
}, 60000);
Expand Down
36 changes: 0 additions & 36 deletions plugins/stock_prices/main.pl

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/stock_prices/plugin.info

This file was deleted.

8 changes: 6 additions & 2 deletions plugins/time_date/main.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import requests
import datetime

# define all commonly used variables here
now = datetime.datetime.now()

response = requests.get('http://127.0.0.1:8000/speak')
def handle(command):

if "time" in command:
time_now = now.strftime("%H:%M:%S")
akulai.speak(f"The current time is{time_now}")
speak(f"The current time is{time_now}")

if "date" in command:
date_now = now.strftime("%Y-%m-%d")
akulai.speak(f"The current date is{date_now}")
speak(f"The current date is{date_now}")

0 comments on commit a6e6077

Please sign in to comment.