Skip to main content

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

# Valid modes: "google", "openai", "termux", "vosk"
VOICE_MODE = os.getenv("VOICE_MODE", "vosk")
if VOICE_MODE not in ("google", "openai", "termux", "vosk"):
    VOICE_MODE = "vosk"

llm_ask.add_tool(
    create_speak_tool(
        mode=VOICE_MODE,
        genai_tts_model="gemini-2.5-flash-preview-tts",  # Optional
        genai_voice_name="Sulafat",  # Optional
        openai_tts_model="tts-1",  # Optional
        openai_voice_name="alloy",  # Optional
        sample_rate_out=24000,  # Optional
    )
)
llm_ask.add_tool(
    create_listen_tool(
        mode=VOICE_MODE,
        genai_stt_model="gemini-2.5-flash",  # Optional
        openai_stt_model="whisper-1",  # Optional
        sample_rate=16000,  # Optional
        channels=1,  # Optional
        silence_threshold=0.01,  # Optional
        max_silence=4.0,  # Optional
    )
)

# 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:

You can also create a TestPypi account:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zrb_extras-0.3.1.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zrb_extras-0.3.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file zrb_extras-0.3.1.tar.gz.

File metadata

  • Download URL: zrb_extras-0.3.1.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for zrb_extras-0.3.1.tar.gz
Algorithm Hash digest
SHA256 408b2dc5e8bf62a29f9b2f348962959bd21e394857770e67f4c1059860e9216a
MD5 eb0b90004c1e21572325d583c591b944
BLAKE2b-256 34b756b5a3381a0af0c08c231fe17102d87edcc3977850f9897f6ab8866e6e50

See more details on using hashes here.

File details

Details for the file zrb_extras-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: zrb_extras-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for zrb_extras-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc31ab1508dd6247e24372b842c2aedc0e16b0a2f16c5462a91547c43c949995
MD5 73b59ee38565cf795e54a3293c7cd3c9
BLAKE2b-256 9c2ad1ee1f880585e5940299ce8d4682d8fcad34381366a111d800b614ed4692

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page