Name | llm-voice JSON |
Version |
0.0.1
JSON |
| download |
home_page | None |
Summary | Library to reduce latency in voice generations from LLM chat completion streams |
upload_time | 2024-06-08 19:32:38 |
maintainer | None |
docs_url | None |
author | Jake Cyr |
requires_python | <4.0,>=3.12 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# LLM Voice
Library to reduce latency in voice generations from LLM chat completion streams.
This lets you generate voices using completely local LLM models, such as Ollama and TTS clients, such as Apple Say and Google Text-to-Speech with the same speed as privately created assistants such as OpenAI.
## Installation and Setup
1. Install the package from PyPI with:
```bash
pip install llm-voice
```
2. Copy the .env.example file to .env and fill in your OpenAI API key if you want to use OpenAI along with the model name for the Ollama/OpenAI model you want to use.
3. Take a look at one of the examples to start generating voice responses in realtime.
## Example Usage
The example below can be found in the [examples](./examples/README.md) directory.
```python
# Setup output device, TTS client and LLM client.
devices: list[AudioDevice] = AudioDevices.get_list_of_devices(
device_type=AudioDeviceType.OUTPUT
)
# Pick the first output device (usually computer builtin speakers if nothing else if connected).
output_device: AudioDevice = devices[0]
# Change to another TTS client depending on your needs and desires.
tts_client: TextToSpeechClient = OpenAITextToSpeechClient()
# Change to another LLM client depending on your needs and desires.
llm_client: LLMClient = OllamaClient(
model_name=MODEL_NAME,
)
# Define messages to send to the LLM.
messages: list[ChatMessage] = [
ChatMessage(
role=MessageRole.SYSTEM,
content="You are a helpful assistant named Alfred.",
),
ChatMessage(role=MessageRole.USER, content="Hey there what is your name?"),
]
# Use the LLM to generate a response.
chat_stream: Iterator[str] = llm_client.generate_chat_completion_stream(
messages=messages,
)
# Create the voice responder and speak the response.
voice_responder_fast = VoiceResponderFast(
text_to_speech_client=tts_client,
output_device=output_device,
)
# Will speak each sentence back to back as it is available.
voice_responder_fast.respond(chat_stream)
```
## Install From Source
```bash
pip install poetry
poetry install
```
## License
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "llm-voice",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.12",
"maintainer_email": null,
"keywords": null,
"author": "Jake Cyr",
"author_email": "cyrjake@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e4/42/58e7210cae570c0aad7576f56c0bb12d74859fde485108bc930d88b93a77/llm_voice-0.0.1.tar.gz",
"platform": null,
"description": "# LLM Voice\n\nLibrary to reduce latency in voice generations from LLM chat completion streams.\n\nThis lets you generate voices using completely local LLM models, such as Ollama and TTS clients, such as Apple Say and Google Text-to-Speech with the same speed as privately created assistants such as OpenAI.\n\n## Installation and Setup\n\n1. Install the package from PyPI with:\n\n ```bash\n pip install llm-voice\n ```\n\n2. Copy the .env.example file to .env and fill in your OpenAI API key if you want to use OpenAI along with the model name for the Ollama/OpenAI model you want to use.\n3. Take a look at one of the examples to start generating voice responses in realtime.\n\n## Example Usage\n\nThe example below can be found in the [examples](./examples/README.md) directory.\n\n```python\n# Setup output device, TTS client and LLM client.\ndevices: list[AudioDevice] = AudioDevices.get_list_of_devices(\n device_type=AudioDeviceType.OUTPUT\n)\n\n# Pick the first output device (usually computer builtin speakers if nothing else if connected).\noutput_device: AudioDevice = devices[0]\n\n# Change to another TTS client depending on your needs and desires.\ntts_client: TextToSpeechClient = OpenAITextToSpeechClient()\n\n# Change to another LLM client depending on your needs and desires.\nllm_client: LLMClient = OllamaClient(\n model_name=MODEL_NAME,\n)\n\n# Define messages to send to the LLM.\nmessages: list[ChatMessage] = [\n ChatMessage(\n role=MessageRole.SYSTEM,\n content=\"You are a helpful assistant named Alfred.\",\n ),\n ChatMessage(role=MessageRole.USER, content=\"Hey there what is your name?\"),\n]\n\n# Use the LLM to generate a response.\nchat_stream: Iterator[str] = llm_client.generate_chat_completion_stream(\n messages=messages,\n)\n\n# Create the voice responder and speak the response.\nvoice_responder_fast = VoiceResponderFast(\n text_to_speech_client=tts_client,\n output_device=output_device,\n)\n\n# Will speak each sentence back to back as it is available.\nvoice_responder_fast.respond(chat_stream)\n```\n\n## Install From Source\n\n```bash\npip install poetry\npoetry install\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Library to reduce latency in voice generations from LLM chat completion streams",
"version": "0.0.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d98463d32108f85066fd807b67dd7bda8053b80e5e035c1c5b2cfd8cdc0c9476",
"md5": "920252d06701ecc174c674e18628342a",
"sha256": "4748ffdd1c84bb91d3b8ce8b60100fe6f83f4a1a6bb17bf568fb51f9a76baf21"
},
"downloads": -1,
"filename": "llm_voice-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "920252d06701ecc174c674e18628342a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 20767,
"upload_time": "2024-06-08T19:32:37",
"upload_time_iso_8601": "2024-06-08T19:32:37.580886Z",
"url": "https://files.pythonhosted.org/packages/d9/84/63d32108f85066fd807b67dd7bda8053b80e5e035c1c5b2cfd8cdc0c9476/llm_voice-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e44258e7210cae570c0aad7576f56c0bb12d74859fde485108bc930d88b93a77",
"md5": "fb29fe66a3e5c3bfd2608e6fe1fbf0d0",
"sha256": "7d110c0f509c5c5362797aa829432d86cd51066c2ec77acbafce42f9d12ce1e1"
},
"downloads": -1,
"filename": "llm_voice-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "fb29fe66a3e5c3bfd2608e6fe1fbf0d0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 12674,
"upload_time": "2024-06-08T19:32:38",
"upload_time_iso_8601": "2024-06-08T19:32:38.773346Z",
"url": "https://files.pythonhosted.org/packages/e4/42/58e7210cae570c0aad7576f56c0bb12d74859fde485108bc930d88b93a77/llm_voice-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-08 19:32:38",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "llm-voice"
}