Generate speech
Generates audio with the specified text for speech synthesis
Function GenerateSpeech(Val URL, Val Token, Val Model, Val Text, Val Voice = "alloy", Val AdditionalParameters = "", Val AdditionalHeaders = "") Export
Parameter | CLI option | Type | Required | Description |
---|---|---|---|---|
URL | --url | String | ✔ | OpenAI server URL |
Token | --token | String | ✔ | OpenAI authorization token |
Model | --model | String | ✔ | Models name |
Text | --input | String | ✔ | Text for speech synthesis |
Voice | --voice | String | ✖ | Voice type: alloy, ash, ballad, coral, echo, etc.. |
AdditionalParameters | --options | Structure Of KeyAndValue | ✖ | Additional request parameters, if necessary |
AdditionalHeaders | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
Returns: Map Of KeyAndValue - Processing result
tip
Method at API documentation: Create speech
Available voices may vary depending on the selected model
The audio file format of the response can be changed by adding response_format
in additional parameters. Available formats: mp3 (default), opus, aac, flac, wav, pcm
1C:Enterprise/OneScript code example
URL = "https://api.athenaeum.digital:1122/";
Token = "sk-or-vv-c5884ebe9f13fb143194bb07ecb...";
Text = "Attack ships on fire off the shoulder of Orion bright as magnesium";
Model = "tts-1";
AdditionalParameters = New Structure("response_format", "wav");
Result = OPI_OpenAI.GenerateSpeech(URL, Token, Model, Text, , AdditionalParameters);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint openai GenerateSpeech \
--url "https://api.athenaeum.digital:1122/" \
--token "***" \
--model "tts-1" \
--input "Attack ships on fire off the shoulder of Orion bright as magnesium" \
--options "{'response_format':'wav'}"
:: JSON data can also be passed as a path to a .json file
oint openai GenerateSpeech ^
--url "https://api.athenaeum.digital:1122/" ^
--token "***" ^
--model "tts-1" ^
--input "Attack ships on fire off the shoulder of Orion bright as magnesium" ^
--options "{'response_format':'wav'}"
Result
NOT JSON: 52 49 46 46 24 49 02 00 57 41 56 45 66 6D 74 20 10 00 00 00 01 00 01 00 80 3E 00 00 00 7D 00 00 02 00 10 00 64 61 74 61 00 49 02 00 FE FF 05 00 05 00 02 00 02 00 04 00 06 00 03 00 01 00 00 00…