Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an API for plugins #14

Open
wants to merge 35 commits into
base: master-v2
Choose a base branch
from

Conversation

Akul2010
Copy link
Member

@Akul2010 Akul2010 commented May 4, 2023

The previous PR, #12, was discontinued because I messed up somewhere and wasn't able to do anything about it. But, I have ported the same changes to this new version with less messy commits.

This basically gives all plugins access to the speak and listen functions when run, so they too can speak and listen when needed rather than printing output in CMD or listening once without follow-up questions.

@Akul2010
Copy link
Member Author

Hi @aaronchantrill, I have made some changes and would like you to review them as I am not as experienced with Perl/JS as I am with Python, so I'm not sure if I got anything wrong. Please try to doit as soon as possible so that I can update the plugins in the akulai-plugins repository when finished.

@aaronchantrill aaronchantrill marked this pull request as ready for review May 24, 2023 19:35
Copy link
Contributor

@aaronchantrill aaronchantrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand what you are doing here, but I'm getting some errors.

I had to move the self... lines just after if __name__ == '__main__' into the init method of the AkulAI() class. Now I'm getting "Error loading ASGI app. Attribute "app" not found in module "akulai". I have tried both running akulai.py and running uvicorn akulai:app --reload and got the same message either way. Do you have some special way you are running this?

I'm not familiar with FastAPI, so it will take me a little time to figure out, so please let me know if this makes sense to you.

Thanks!

@aaronchantrill
Copy link
Contributor

Okay, I think I understand what the problem was. I had to move the api setup stuff above the if name == main but below the AkulAI() class definition. Then I changed it to use different paths for speak and listen:

@app.get("/speak/{text}")
async def speak(text: str):
    akulai.speak(text)
    return {"message": "Text synthesized"}

@app.post("/listen")
async def listen():
    akulai.listen()
    return {"message": "Listening..."}

At that point I was able to start the program and then navigate to http://localhost:8000/speak/Hello+There to get it to say "Hello plus There". I guess it does not automatically urldecode the query string values.

@Akul2010
Copy link
Member Author

I will add your proposed changes right now. I'm not sure how I would implement urldecode, however.

@aaronchantrill
Copy link
Contributor

I'm still having some issues with this. I'll try to submit a pull request. I'm trying to figure out why it won't shut down when I ask it to right now. Are you running this code on your system?

@Akul2010
Copy link
Member Author

Yes, I just pressed Ctrl+C and ignored it, because I considered it a trivial problem. I'll look into it now, though.

Refers to this code block:
```
# Create the listening thread
    akulai.stop_listening = threading.Event()
    akulai.listening_thread = threading.Thread(target=akulai.listen)
    akulai.listening_thread.start()
```
Since it is no longer in the `AkulAI` class, I made an object for it and used that instead.
We are very close to releasing 2.0, and so I wanted to double check everything, starting with scripts. However, I noticed so many things wrong with it. This is just fixing the setup.bat file, but I also want to cut things from other scripts. For example, I am considering putting plugins in here by default, rather than having to install them. (VOSK and all the other programs would still be in the script because they are too large to include here.)
It seems the problem was that the `.gitmodules` file already had the submodule for plugins in it, so it wasn't working. It should now, although for updating plugins, I might switch from git submodules to something else.
@Akul2010
Copy link
Member Author

Akul2010 commented Aug 7, 2023

There seems to be a problem where the plugins can't access the FastAPI server. I'm not sure what is causing this, any ideas?

@Akul2010 Akul2010 added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Nov 17, 2023
@Akul2010
Copy link
Member Author

Rather than calling through a server, I'm thinking we could just wrap the functions into a command line interface, through which the respective languages will have their own functions for. (for example, JS listen function will run a command in js to run the listen function)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants