Solution needed for async PHP calls

[ad_1]

I am working on a ChatGPT plugin which will operate and respond with voice, and I sort of need yoour advice on the back-end part of the text-to-speech portion.

Specifically for text-to-speech I am using php/cURL as the backend which works fine if the text that needs to be modified is relatively short, otherwise you wait for too long because cURL is synchronous and need to finish the download from the server before continouing.

Now, openAI API comes with a streaming option but I do not how to use it correctly because I would need to make async PHP calls to the openAI server which rather tricky.

What would be your advice dealing with these async calls:
a) use a PHP library, and if yes which one?
b) should I make these calls outside wordpress like perhaps integrating with node-js?
c) something else?

[ad_2]
2 Comments
  1. Ask ChatGTP. ![gif](emote|free_emotes_pack|grin)

    Seriously though, you may want to cross-post in r/PHPhelp or r/phpHelpWithProjects, the question isn’t necessarily WordPress-specific, even though you are making a plugin.

    I googled “Async PHP” and found many answers about how to connect that way.

    [https://www.geeksforgeeks.org/how-to-make-async-functions-in-php/](https://www.geeksforgeeks.org/how-to-make-async-functions-in-php/)

    This article suggests that you must use reactPHP or AMP.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer