Title: OpenAI Text-to-Speech
Author: Alex Kirk
Published: November 7, 2023

---

# OpenAI Text-to-Speech

November 7, 2023

It has been a somewhat interesting coincidence that I am currently without voice
because of a cold, and [OpenAI has just released](https://openai.com/blog/new-models-and-developer-products-announced-at-devday)
some really good Text-to-Speech voices with their [Create speech API](https://platform.openai.com/docs/api-reference/audio/createSpeech).
So in preparation for a meeting today, [I created a little script](https://github.com/akirk/chat-cli/blob/main/talk.php)
that will output the spoke audio what I typed.

Since the voice will read exactly what’s there, I added a spell fixer that will (
through ChatGPT) automatically fix typos before it’s sent to the audio API.

    ```wp-block-code
    $ php talk.php
    Voice: echo
    Fix spelling: off
    Speed: 1.0
    > hi everyone and welcoem to tis meetin
    > sc
    Fix spelling: on
    > hi everyone and welcoem to tis meetin
    Hi everyone and welcome to this meeting.
    > s2
    Speed: 2
    > my voice is gone because of a pretty string cold that iv pickd up
    My voice is gone because of a pretty strong cold that I've picked up.
    > s1.1
    Speed: 1.1
    > my voice is gone because of a pretty string cold that iv pickd up
    My voice is gone because of a pretty strong cold that I've picked up.
    > turns out, even suing the streaming audio aip, typing and then waiting for the srsult is too lsow for a conversation. but it's been interesting
    Turns out, even using the streaming audio API, typing and then waiting for the result is too slow for a conversation. But it's been interesting.
    > sc
    Fix spelling: off
    > without spell fixer it's faster but for good intonation it only makes sense to send full sentences, not single words as soon as they have been typed. maybe that can also be solved, but that's for the next experiment
    ```

In any case, it’s been fun. Thanks [Simon for highlighting the API](https://simonwillison.net/2023/Nov/7/ospeak/).

[Web](https://alex.kirk.at/category/web/)

Read this next

[Previous Post](https://alex.kirk.at/2023/11/07/1896312/)

### Leave a Reply 󠀁[Cancel reply](https://alex.kirk.at/2023/11/07/openai-text-to-speech/?output_format=md#respond)󠁿

Only people in [my network](https://alex.kirk.at/friends/) can comment.

This site uses Akismet to reduce spam. [Learn how your comment data is processed.](https://akismet.com/privacy/)