Skip to content

Commit

Permalink
Merge pull request #40 from ovistoica/main
Browse files Browse the repository at this point in the history
Add support for Speech API
  • Loading branch information
wkok authored Nov 19, 2023
2 parents 5c94fb2 + 05dc5cb commit 33ef132
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/wkok/openai_clojure/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/wkok/openai_clojure/api_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 33ef132

Please sign in to comment.