You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-27 22:18:36 +02:00
88 lines
3.3 KiB
Plaintext
Vendored
88 lines
3.3 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 1
|
|
description: Generate speech and other functions to work with OpenAI in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
|
|
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, OpenAI]
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
# 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: BinaryData - Processing result
|
|
|
|
<br/>
|
|
|
|
:::tip
|
|
Method at API documentation: [Create speech](https://platform.openai.com/docs/api-reference/audio/createSpeech)
|
|
|
|
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
|
|
:::
|
|
<br/>
|
|
|
|
|
|
```bsl title="1C:Enterprise/OneScript code example"
|
|
URL = "https://hut.openintegrations.dev/localai/";
|
|
Token = "12We...";
|
|
|
|
Text = "Attack ships on fire off the shoulder of Orion bright as magnesium";
|
|
Model = "bark-cpp-small";
|
|
|
|
AdditionalParameters = New Structure("response_format", "wav");
|
|
|
|
Result = OPI_OpenAI.GenerateSpeech(URL, Token, Model, Text, , AdditionalParameters);
|
|
```
|
|
|
|
|
|
<Tabs>
|
|
|
|
<TabItem value="bash" label="Bash" default>
|
|
```bash
|
|
# JSON data can also be passed as a path to a .json file
|
|
|
|
oint openai GenerateSpeech \
|
|
--url "https://hut.openintegrations.dev/localai/" \
|
|
--token "***" \
|
|
--model "bark-cpp-small" \
|
|
--input "Attack ships on fire off the shoulder of Orion bright as magnesium" \
|
|
--options "{'response_format':'wav'}"
|
|
```
|
|
</TabItem>
|
|
|
|
<TabItem value="bat" label="CMD/Bat" default>
|
|
```batch
|
|
:: JSON data can also be passed as a path to a .json file
|
|
|
|
oint openai GenerateSpeech ^
|
|
--url "https://hut.openintegrations.dev/localai/" ^
|
|
--token "***" ^
|
|
--model "bark-cpp-small" ^
|
|
--input "Attack ships on fire off the shoulder of Orion bright as magnesium" ^
|
|
--options "{'response_format':'wav'}"
|
|
```
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
|
|
```json title="Result"
|
|
NOT JSON: 52 49 46 46 24 59 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 59 02 00 FD FF 04 00 03 00 00 00 00 00 03 00 06 00 03 00 01 00 00 00…
|
|
```
|