B4J Question OpenAI Text To Speech Problems [SOLVED]

Tim Chapman

Active Member
Licensed User
Longtime User
I have supplied my code with my OpenAI API key so that it will be simple for anyone to run the code for troubleshooting purposes. I will be removing that key from my OpenAI profile very soon since it can't remain exposed to the public. Hopefully this will make it easier for anyone to assist me on this problem. Just run the code and you will see the issues.

I have converted the OpenAI library to a Class module for easier troubleshooting.
I have modified the OpenAI Class to allow me to specify the location I want the mp3 file saved.

I run the code and put in a text. I click the far right label which I have made to give a speech response. I get an error that the media player is not initialized, but it still plays the mp3 file created by the TTS response from OpenAI.

Any ideas why this is happening? I have been fighting it for many hours and can't get a smooth run with the TTS response.
If I click the TTS response button again, it plays the mp3 file twice. Also an irregularity.
 

Attachments

  • OpenAIChatImage.zip
    11.6 KB · Views: 61
Last edited:
Solution
I found my error finally. In the Sub OpenAI_TextToSpeech_Bot, the last line OpenAI_TTSResponse(savePath, "tts.mp3") was not supposed to be there.
Note that in the attached code, the OpenAI library is modified to allow the user to select the path were the mp3 file gets saved.
Since I don't have permission to update the OpenAI library and don't know how myself, this is it.

Tim Chapman

Active Member
Licensed User
Longtime User
I found my error finally. In the Sub OpenAI_TextToSpeech_Bot, the last line OpenAI_TTSResponse(savePath, "tts.mp3") was not supposed to be there.
Note that in the attached code, the OpenAI library is modified to allow the user to select the path were the mp3 file gets saved.
Since I don't have permission to update the OpenAI library and don't know how myself, this is it.
 

Attachments

  • OpenAIChatImage.zip
    11.4 KB · Views: 64
Upvote 0
Solution
Top