From 05dc5cb1872c210fa61966c6871b6eea5d56937d Mon Sep 17 00:00:00 2001 From: Ovi Stoica Date: Fri, 17 Nov 2023 10:00:31 +0200 Subject: [PATCH] Add support for Speech API --- src/wkok/openai_clojure/api.clj | 17 +++++++++++++++++ test/wkok/openai_clojure/api_test.clj | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/wkok/openai_clojure/api.clj b/src/wkok/openai_clojure/api.clj index 4f4310b..d95bba6 100644 --- a/src/wkok/openai_clojure/api.clj +++ b/src/wkok/openai_clojure/api.clj @@ -222,6 +222,23 @@ ([params options] (core/response-for :create-translation params options))) +(defn create-speech + "Creates audio from text. + + Example: + ``` + (create-speech {:model \"tts-1\" + :input \"Hello! Nice to meet you!.\" + :voice \"alloy\" + :response_format \"mp3\"}) + ``` + Also see the [OpenAI documentation](https://platform.openai.com/docs/api-reference/audio/createSpeech) + " + ([params] + (create-speech params nil)) + ([params options] + (core/response-for :create-speech params options))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Files diff --git a/test/wkok/openai_clojure/api_test.clj b/test/wkok/openai_clojure/api_test.clj index b3bae67..9a4bc86 100644 --- a/test/wkok/openai_clojure/api_test.clj +++ b/test/wkok/openai_clojure/api_test.clj @@ -142,6 +142,11 @@ (is (= :success (api/create-translation {:file (io/file "path/to/file/german.m4a") :model "whisper-1"}))) + (is (= :success + (api/create-speech {:model "tts-1" + :input "Hey there! Nice to meet you!" + :voice "alloy" + :response_format "mp3"}))) (is (= :success (api/list-files)))