-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "liboai/include/liboai.h" | ||
|
||
using namespace liboai; | ||
|
||
int main() { | ||
OpenAI oai; | ||
|
||
if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) { | ||
try { | ||
std::ofstream ocout("demo.mp3", std::ios::binary); | ||
auto fut = oai.Audio->speech_async( | ||
"tts-1", | ||
"alloy", | ||
"Today is a wonderful day to build something people love!" | ||
); | ||
// do other work... | ||
|
||
// check if the future is ready | ||
fut.wait(); | ||
|
||
// get the contained response | ||
auto res = fut.get(); | ||
|
||
ocout << res.content; | ||
ocout.close(); | ||
std::cout << res.content.size() << std::endl; | ||
} | ||
catch (const std::exception& e) { | ||
std::cout << e.what() << std::endl; | ||
} | ||
} | ||
} |