1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2026-05-18 09:51:28 +02:00
Files
OpenIntegrations/docs/en/md/OpenAI/Audio-processing/Generate-speech.mdx
T

109 lines
4.1 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';
import Admonition from '@theme/Admonition';
# Generate speech
Generates audio with the specified text for speech synthesis
<Tabs>
<TabItem value="params" label="Parameters" default>
`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 | &#x2714; | OpenAI server URL |
| Token | --token | String | &#x2714; | OpenAI authorization token |
| Model | --model | String | &#x2714; | Models name |
| Text | --input | String | &#x2714; | Text for speech synthesis |
| Voice | --voice | String | &#x2716; | Voice type: alloy, ash, ballad, coral, echo, etc.. |
| AdditionalParameters | --options | Structure Of KeyAndValue | &#x2716; | Additional request parameters, if necessary |
| AdditionalHeaders | --headers | Map Of KeyAndValue | &#x2716; | Additional request headers, if necessary |
<div className="return-value-note">
<div className="return-value-note__title">Returns</div>
<div className="return-value-note__value">
BinaryData - Processing result
</div>
</div>
</TabItem>
<TabItem value="extended" label={<span>Advanced call{' '}<a href="/docs/Start/Advanced-call" target="_blank" rel="noreferrer" title="About advanced call" onClick={(e) => e.stopPropagation()}>?</a></span>}>
| Parameter | Description |
|---|---|
| proxy | InternetProxy or a structure with fields Protocol, Host, Port, User, Password, UseOSAuthentication |
| timeout | Request execution timeout |
| adv_response | Formats the response as a complete structure with fields code, body, and headers |
</TabItem>
</Tabs>
:::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 = "12We34...";
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…
```