wyoming-openai 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,330 @@
1
+ Metadata-Version: 2.4
2
+ Name: wyoming_openai
3
+ Version: 0.3.2
4
+ Summary: OpenAI-Compatible Proxy Middleware for the Wyoming Protocol
5
+ Author: Rory Eckel
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/roryeckel/wyoming_openai
8
+ Project-URL: Issues, https://github.com/roryeckel/wyoming_openai/issues
9
+ Keywords: proxy,tts,openai,home-assistant,stt,asr,wyoming
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.12
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: openai==1.86.0
19
+ Requires-Dist: wyoming==1.6.1
20
+ Provides-Extra: dev
21
+ Requires-Dist: ruff==0.11.10; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # Wyoming OpenAI
25
+
26
+ OpenAI-Compatible Proxy Middleware for the Wyoming Protocol
27
+
28
+ **Author:** Rory Eckel
29
+
30
+ Note: This project is not affiliated with OpenAI or the Wyoming project.
31
+
32
+ ## Overview
33
+
34
+ This project introduces a [Wyoming](https://github.com/rhasspy/wyoming) server that connects to OpenAI-compatible endpoints of your choice. Like a proxy, it enables Wyoming clients such as the [Home Assistant Wyoming Integration](https://www.home-assistant.io/integrations/wyoming/) to use the transcription (Automatic Speech Recognition - ASR) and text-to-speech synthesis (TTS) capabilities of various OpenAI-compatible projects. By acting as a bridge between the Wyoming protocol and OpenAI, you can consolidate the resource usage on your server and extend the capabilities of Home Assistant.
35
+
36
+ ## Objectives
37
+
38
+ 1. **Wyoming Server, OpenAI-compatible Client**: Function as an intermediary between the Wyoming protocol and OpenAI's ASR and TTS services.
39
+ 2. **Service Consolidation**: Allow users of various programs to run inference on a single server without needing separate instances for each service.
40
+ Example: Sharing TTS/STT services between [Open WebUI](#open-webui) and [Home Assistant](#usage-in-home-assistant).
41
+ 3. **Asynchronous Processing**: Enable efficient handling of multiple requests by supporting asynchronous processing of audio streams.
42
+ 4. **Simple Setup with Docker**: Provide a straightforward deployment process using [Docker and Docker Compose](#docker-recommended) for OpenAI and various popular open source projects.
43
+
44
+ ## Terminology
45
+
46
+ - **TTS (Text-to-Speech)**: The process of converting text into audible speech output.
47
+ - **ASR (Automatic Speech Recognition) / STT (Speech-to-Text)**: Technologies that convert spoken language into written text. ASR and STT are often used interchangeably to describe this function.
48
+
49
+ ## Installation (Local Development)
50
+
51
+ ### Prerequisites
52
+
53
+ - Tested with Python 3.12
54
+ - Optional: OpenAI API key(s) if using proprietary models
55
+
56
+ ### Instructions
57
+
58
+ 1. **Clone the Repository**
59
+
60
+ ```bash
61
+ git clone https://github.com/roryeckel/wyoming-openai.git
62
+ cd wyoming-openai
63
+ ```
64
+
65
+ 2. **Create a Virtual Environment** (optional but recommended)
66
+
67
+ ```bash
68
+ python3 -m venv venv
69
+ source venv/bin/activate # On Windows use `venv\Scripts\activate`
70
+ ```
71
+
72
+ 3. **Install as a Development Package**
73
+
74
+ ```bash
75
+ pip install -e .
76
+ ```
77
+ Assuming you have activated a virtual environment, the wyoming_openai package will be installed into it. This will build and install the package in editable mode, allowing you to make changes to the code without needing to reinstall it each time.
78
+
79
+ Or, if you prefer to install it as a regular (production) package:
80
+
81
+ ```bash
82
+ pip install .
83
+ ```
84
+
85
+ This is more suitable for a global installation.
86
+
87
+ 4. **Configure Environment Variables or Command Line Arguments**
88
+
89
+ ## Command Line Arguments
90
+
91
+ The proxy server can be configured using several command line arguments to tailor its behavior to your specific needs.
92
+
93
+ ### Example Usage
94
+
95
+ Assuming you have installed the package in your current environment, you can run the server with the following command:
96
+
97
+ ```bash
98
+ python -m wyoming_openai \
99
+ --uri tcp://0.0.0.0:10300 \
100
+ --log-level INFO \
101
+ --languages en \
102
+ --stt-openai-key YOUR_STT_API_KEY_HERE \
103
+ --stt-openai-url https://api.openai.com/v1 \
104
+ --stt-models gpt-4o-transcribe gpt-4o-mini-transcribe whisper-1 \
105
+ --stt-backend OPENAI \
106
+ --tts-openai-key YOUR_TTS_API_KEY_HERE \
107
+ --tts-openai-url https://api.openai.com/v1 \
108
+ --tts-models gpt-4o-mini-tts tts-1-hd tts-1 \
109
+ --tts-voices alloy ash coral echo fable onyx nova sage shimmer \
110
+ --tts-backend OPENAI \
111
+ --tts-speed 1.0
112
+ ```
113
+
114
+ ## Configuration Options
115
+
116
+ In addition to using command-line arguments, you can configure the Wyoming OpenAI proxy server via environment variables. This is especially useful for containerized deployments.
117
+
118
+ ### Table of Environment & Command Line Options
119
+
120
+ | **Command Line Argument** | **Environment Variable** | **Default Value** | **Description** |
121
+ |-----------------------------------------|--------------------------------------------|-----------------------------------------------|----------------------------------------------------------------------|
122
+ | `--uri` | `WYOMING_URI` | tcp://0.0.0.0:10300 | The URI for the Wyoming server to bind to. |
123
+ | `--log-level` | `WYOMING_LOG_LEVEL` | INFO | Sets the logging level (e.g., INFO, DEBUG). |
124
+ | `--languages` | `WYOMING_LANGUAGES` | en | Space-separated list of supported languages to advertise. |
125
+ | `--stt-openai-key` | `STT_OPENAI_KEY` | None | Optional API key for OpenAI-compatible speech-to-text services. |
126
+ | `--stt-openai-url` | `STT_OPENAI_URL` | https://api.openai.com/v1 | The base URL for the OpenAI-compatible speech-to-text API |
127
+ | `--stt-models` | `STT_MODELS` | gpt-4o-transcribe gpt-4o-mini-transcribe whisper-1 | Space-separated list of models to use for the STT service. |
128
+ | `--stt-backend` | `STT_BACKEND` | None (autodetected) | Enable unofficial API feature sets. |
129
+ | `--stt-temperature` | `STT_TEMPERATURE` | None (autodetected) | Sampling temperature for speech-to-text (ranges from 0.0 to 1.0) |
130
+ | `--stt-prompt` | `STT_PROMPT` | None | Optional prompt for STT requests (Text to guide the model's style). |
131
+ | `--tts-openai-key` | `TTS_OPENAI_KEY` | None | Optional API key for OpenAI-compatible text-to-speech services. |
132
+ | `--tts-openai-url` | `TTS_OPENAI_URL` | https://api.openai.com/v1 | The base URL for the OpenAI-compatible text-to-speech API |
133
+ | `--tts-models` | `TTS_MODELS` | gpt-4o-mini-tts tts-1-hd tts-1 | Space-separated list of models to use for the TTS service. |
134
+ | `--tts-voices` | `TTS_VOICES` | Empty (autodetected) | Space-separated list of voices for TTS. |
135
+ | `--tts-backend` | `TTS_BACKEND` | None (autodetected) | Enable unofficial API feature sets. |
136
+ | `--tts-speed` | `TTS_SPEED` | None (autodetected) | Speed of the TTS output (ranges from 0.25 to 4.0). |
137
+ | `--tts-instructions` | `TTS_INSTRUCTIONS` | None | Optional instructions for TTS requests (Control the voice). |
138
+
139
+ ## Docker (Recommended)
140
+
141
+ ### Prerequisites
142
+
143
+ - Ensure you have [Docker](https://www.docker.com/products/docker-desktop) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your system.
144
+
145
+ ### Deployment Options
146
+
147
+ You can deploy the Wyoming OpenAI proxy server in different environments depending on whether you are using official OpenAI services or a local alternative like Speaches. You can even run multiple wyoming_openai instances on different ports for different purposes. Below are example scenarios:
148
+
149
+ #### 1. Deploying with Official OpenAI Services
150
+
151
+ To set up the Wyoming OpenAI proxy to work with official OpenAI APIs, follow these steps:
152
+
153
+ - **Environment Variables**: Create a `.env` file in your project directory that includes necessary environment variables such as `STT_OPENAI_KEY`, `TTS_OPENAI_KEY`.
154
+
155
+ - **Docker Compose Configuration**: Use the provided `docker-compose.yml` template. This setup binds a Wyoming server to port 10300 and uses environment variables for OpenAI URLs, model configurations, and voices as specified in the compose file.
156
+
157
+ - **Command**:
158
+
159
+ ```bash
160
+ docker compose -f docker-compose.yml up -d
161
+ ```
162
+
163
+ #### 2. Deploying with Speaches Local Service
164
+
165
+ If you prefer using a local service like Speaches instead of official OpenAI services, follow these instructions:
166
+
167
+ - **Docker Compose Configuration**: Use the `docker-compose.speaches.yml` template which includes configuration for both the Wyoming OpenAI proxy and the Speaches service.
168
+
169
+ - **Speaches Setup**:
170
+ - The Speaches container is configured with specific model settings (`Systran/faster-distil-whisper-large-v3` for STT and `speaches-ai/Kokoro-82M-v1.0-ONNX` for TTS).
171
+ - It uses a local port (8000) to expose the Speaches service.
172
+ - NVIDIA GPU support is enabled, so ensure your system has an appropriate setup if you plan to utilize GPU resources.
173
+
174
+ - **Command**:
175
+
176
+ ```bash
177
+ docker compose -f docker-compose.speaches.yml up -d
178
+ ```
179
+
180
+ #### 3. Deploying with Kokoro-FastAPI and Speaches Local Services
181
+
182
+ For users preferring a setup that leverages Kokoro-FastAPI for TTS and Speaches for STT, follow these instructions:
183
+
184
+ - **Docker Compose Configuration**: Use the `docker-compose.kokoro-fastapi.yml` template which includes configuration for both the Wyoming OpenAI proxy and Kokoro-FastAPI TTS service (Kokoro).
185
+
186
+ - **Speaches Setup**:
187
+ - Use it in combination with the Speaches container for access to STT.
188
+
189
+ - **Kokoro Setup**:
190
+ - The Kokoro-FastAPI container provides TTS capabilities.
191
+ - It uses a local port (8880) to expose the Kokoro service.
192
+ - NVIDIA GPU support is enabled, so ensure your system has an appropriate setup if you plan to utilize GPU resources.
193
+
194
+ - **Command**:
195
+
196
+ ```bash
197
+ docker compose -f docker-compose.speaches.yml -f docker-compose.kokoro-fastapi.yml up -d
198
+ ```
199
+
200
+ #### 4. Development with Docker
201
+
202
+ If you are developing the Wyoming OpenAI proxy server and want to build it from source, use the `docker-compose.dev.yml` file along with the base configuration.
203
+
204
+ - **Command**:
205
+
206
+ ```bash
207
+ docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build
208
+ ```
209
+
210
+ #### 5. Example: Development with Additional Local Service
211
+
212
+ For a development setup using the Speaches local service, combine `docker-compose.speaches.yml` and `docker-compose.dev.yml`. This also works for `docker-compose.kokoro-fastapi.yml`.
213
+
214
+ - **Command**:
215
+
216
+ ```bash
217
+ docker compose -f docker-compose.speaches.yml -f docker-compose.dev.yml up -d --build
218
+ ```
219
+
220
+ #### 6. Docker Tags
221
+
222
+ We follow specific tagging conventions for our Docker images. These tags help in identifying the version and branch of the code that a particular Docker image is based on.
223
+
224
+ - **`latest`**: This tag always points to the latest stable release of the Wyoming OpenAI proxy server. It is recommended for users who want to run the most recent, well-tested version without worrying about specific versions.
225
+
226
+ - **`main`**: This tag points to the latest commit on the main code branch. It is suitable for users who want to experiment with the most up-to-date features and changes, but may include unstable or experimental code.
227
+
228
+ - **`major.minor.patch version`**: Specific version tags (e.g., `0.3.1`) correspond to specific stable releases of the Wyoming OpenAI proxy server. These tags are ideal for users who need a consistent, reproducible environment and want to avoid breaking changes introduced in newer versions.
229
+
230
+ - **`major.minor version`**: Tags that follow the `major.minor` format (e.g., `0.2`) represent a range of patch-level updates within the same minor version series. These tags are useful for users who want to stay updated with bug fixes and minor improvements without upgrading to a new major or minor version.
231
+
232
+ ### General Deployment Steps
233
+
234
+ 1. **Start Services**: Run the appropriate Docker Compose command based on your deployment option.
235
+ 2. **Verify Deployment**: Ensure that all services are running by checking the logs with `docker compose logs -f` or accessing the Wyoming OpenAI proxy through its exposed port (e.g., 10300) to ensure it responds as expected.
236
+ 3. **Configuration Changes**: You can modify environment variables in the `.env` file or directly within your Docker Compose configuration files to adjust settings such as languages, models, and voices without rebuilding containers.
237
+
238
+ ## Usage in Home Assistant
239
+
240
+ 1. Install & set up your Wyoming OpenAI instance using one of the [deployment options](#deployment-options) above.
241
+ 2. In HA, Go to Settings, Devices & Services, Add Integration, and search for Wyoming Protocol. Add the Wyoming Protocol integration with the URI of your Wyoming OpenAI instance.
242
+ 3. The hard part is over! Configure your Voice Assistant pipeline to use the STT/TTS services provided by your new Wyoming OpenAI instance.
243
+
244
+ #### Reloading Configuration Changes in Home Assistant
245
+
246
+ When you make changes to your configuration such as updating models, voices, or URLs, it's important to reload the Wyoming OpenAI integration in Home Assistant to apply these changes. Here's how to do it:
247
+
248
+ 1. Go to **Settings** > **Devices & Services**
249
+ 2. Find and select your **Wyoming OpenAI** integration
250
+ 3. Click on **Reload**
251
+
252
+ ### Sequence Diagrams
253
+
254
+ #### Home Assistant
255
+
256
+ Home Assistant uses the Wyoming Protocol integration to communicate with the Wyoming OpenAI proxy server. The proxy server then communicates with the OpenAI API to perform the requested ASR or TTS tasks. The results are then sent back to Home Assistant.
257
+
258
+ ```mermaid
259
+ sequenceDiagram
260
+ participant HA as Home Assistant
261
+ participant WY as wyoming_openai
262
+ participant OAPI as OpenAI API
263
+ Note over HA,OAPI: Speech-to-Text (STT/ASR) Flow
264
+ HA->>WY: Transcribe event
265
+ HA->>WY: AudioStart event
266
+ loop Audio Streaming
267
+ HA->>WY: AudioChunk events
268
+ Note over WY: Buffers WAV data
269
+ end
270
+ HA->>WY: AudioStop event
271
+ WY->>OAPI: Send complete audio file
272
+ OAPI-->>WY: Text transcript response
273
+ WY-->>HA: Transcript event
274
+ Note over HA,OAPI: Text-to-Speech (TTS) Flow
275
+ HA->>WY: Synthesize event (text + voice)
276
+ WY->>OAPI: Speech synthesis request
277
+ WY->>HA: AudioStart event
278
+ loop Audio Streaming
279
+ OAPI-->>WY: Audio stream chunks
280
+ WY-->>HA: AudioChunk events
281
+ end
282
+ WY->>HA: AudioStop event
283
+ ```
284
+
285
+ #### Open WebUI
286
+
287
+ No proxy is needed for Open WebUI, because it has native support for OpenAI-compatible endpoints.
288
+
289
+ ```mermaid
290
+ sequenceDiagram
291
+ participant OW as Open WebUI
292
+ participant OAPI as OpenAI API
293
+
294
+ Note over OW,OAPI: Speech-to-Text (STT/ASR) Flow
295
+ OW->>OAPI: Direct audio transcription request
296
+ OAPI-->>OW: Text transcript response
297
+
298
+ Note over OW,OAPI: Text-to-Speech (TTS) Flow
299
+ OW->>OAPI: Direct speech synthesis request
300
+ OAPI-->>OW: Audio stream response
301
+
302
+ ```
303
+
304
+ ## Future Plans (Descending Priority)
305
+
306
+ - Improved streaming support directly to OpenAI APIs
307
+ - Reverse direction support (Server for OpenAI compatible endpoints - possibly FastAPI)
308
+ - OpenAI Realtime API
309
+
310
+ ## Contributing
311
+
312
+ Contributions are welcome! Please feel free to open issues or submit pull requests. For major changes, please first discuss the proposed changes in an issue.
313
+
314
+ ## Linting and Code Quality (Ruff)
315
+
316
+ This project uses [Ruff](https://github.com/astral-sh/ruff) for linting and code quality checks. Ruff is a fast Python linter written in Rust that can replace multiple tools like flake8, isort, and more.
317
+
318
+ To use Ruff during development:
319
+
320
+ 1. Install development dependencies:
321
+ ```bash
322
+ pip install -e ".[dev]"
323
+ ```
324
+
325
+ 2. Run Ruff to check your code:
326
+ ```bash
327
+ ruff check .
328
+ ```
329
+
330
+ The project includes a GitHub Action that automatically runs Ruff on all pull requests and branch pushes to ensure code quality.