Collection of Zrb additional utilities
Project description
Zrb extras
zrb-extras is a pypi package.
You can install zrb-extras by invoking the following command:
pip install zrb-extras
Let your LLMTask speak and listen
Prerequisites
Termux
First of all, make sure termux has permission to access microphone/speaker
pkg update && pkg upgrade -y
pkg install pulseaudio termux-api -y
Run the following script or add it to ~/.bashrc
# start PulseAudio daemon
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
# load module now (if it errors, check you gave Termux:API mic permission and restart Termux)
pactl load-module module-sles-source
# confirm source exists
pactl list short sources
# Start proot-distro
proot-distro login ubuntu
Proot-distro (Ubuntu)
apt install libasound2-dev portaudio19-dev pulseaudio
Create zrb_init.py
import os
from zrb.builtin import llm_ask
from zrb import llm_config
from zrb_extras.llm.tool import create_listen_tool, create_speak_tool
API_KEY = os.getenv("GOOGLE_API_KEY", "")
llm_ask.add_tool(
create_speak_tool(
api_key=API_KEY, # Optional, by default taken from GEMINI_API_KEY or GOOOGLE_API_KEY
stt_model="gemini-2.5-flash-preview-tts", # Optional
voice_name="Sulafat", # Optional (https://ai.google.dev/gemini-api/docs/speech-generation#voices)
sample_rate_out=24000, # Optional
)
)
llm_ask.add_tool(
create_listen_tool(
api_key=API_KEY, # Optional, by default taken from GEMINI_API_KEY or GOOOGLE_API_KEY
tts_model="gemini-2.5-flash", # Optional
sample_rate=16000, # Optional
channels=1, # Optional
silence_threshold=0.01, # Optional (smaller means more sensitive)
max_silence=4.0, # Optional (4 second silence before stop listening)
)
)
# Optional: allow LLM to speak or listen without asking for user approval
if not llm_config.default_yolo_mode:
llm_config.set_default_yolo_mode(["speak", "listen"])
For maintainers
Publish to pypi
To publish zrb-extras, you need to have a Pypi account:
- Log in or register to https://pypi.org/
- Create an API token
You can also create a TestPypi account:
- Log in or register to https://test.pypi.org/
- Create an API token
Once you have your API token, you need to configure poetry:
poetry config pypi-token.pypi <your-api-token>
To publish zrb-extras, you can do the following command:
poetry publish --build
Updating version
You can update zrb-extras version by modifying the following section in pyproject.toml:
[project]
version = "0.0.2"
Adding dependencies
To add zrb-extras dependencies, you can edit the following section in pyproject.toml:
[project]
dependencies = [
"Jinja2==3.1.2",
"jsons==1.6.3"
]
Adding script
To make zrb-extras executable, you can edit the following section in pyproject.toml:
[project-scripts]
zrb-extras-hello = "zrb_extras.__main__:hello"
Now, whenever you run zrb-extras-hello, the main function on your __main__.py will be executed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zrb_extras-0.1.1.tar.gz.
File metadata
- Download URL: zrb_extras-0.1.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.11.9 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba0f396fb5a74094649b4f525456149dd06991cb3da36d5078c50e6cbe546577
|
|
| MD5 |
a9e3e8e29b424a2956e3b15b756041e6
|
|
| BLAKE2b-256 |
2818b019e4b542f0c311392aa143ab1e6f1c057488e8bf6f3a7e18d41310851d
|
File details
Details for the file zrb_extras-0.1.1-py3-none-any.whl.
File metadata
- Download URL: zrb_extras-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.4 CPython/3.11.9 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d77b3f885597e35433e254561b8a632cf61c6d4b8c26a5ff4158f6603ec44e76
|
|
| MD5 |
70027944093868e2a16f72cae553b298
|
|
| BLAKE2b-256 |
08b54d43fdff44201d23556828059fe748ce151e11c414d2848c93ff12259eae
|