Skip to main content

A Python package for speech recognition.

Project description

ClaraSR

A Python package for speech recognition and command processing with wake word detection.

Features

  • Continuous speech recognition
  • Configurable wake word detection
  • Real-time audio processing
  • Command extraction and processing
  • Simple and intuitive API

Installation

pip install clarasr

Requirements

  • Python 3.6 or higher
  • PyAudio
  • SpeechRecognition
  • NumPy
  • PyTorch
  • Requests

Quick Start

from clarasr import config, startup, get, exit

# Configure the system (optional)
config(wake_word="clara", energy_threshold=1000)

# Start the speech recognition system
startup()

try:
    while True:
        # Get the latest recognized text
        text = get()
        if text:
            print(f"Recognized: {text}")
        time.sleep(0.1)
except KeyboardInterrupt:
    # Clean up and exit
    exit()

API Reference

Configuration

config(
    wake_word="clara",           # The word to trigger command processing
    energy_threshold=1000,       # Audio energy threshold for silence detection
    processing_delay=1.5,        # Delay between wake word detections (seconds)
    min_command_length=3         # Minimum words for a valid command
)

Core Functions

  • startup(): Start the speech recognition system
  • get(): Get the latest recognized text
  • exit(): Stop the speech recognition system

Advanced Usage

from clarasr import (
    AudioSegment,
    detect_silence,
    contains_wake_word,
    find_wake_word_position,
    extract_command,
    process_command
)

# Example of custom command processing
def custom_process_command(command):
    if command:
        print(f"Processing custom command: {command}")
        return True
    return False

# Configure and start the system
config(wake_word="assistant")
startup()

try:
    while True:
        text = get()
        if text:
            # Custom command processing
            if contains_wake_word(text, "assistant"):
                command = extract_command([AudioSegment(text, datetime.now(), b"")], "assistant")
                if command:
                    custom_process_command(command)
        time.sleep(0.1)
except KeyboardInterrupt:
    exit()

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

clarasr-0.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

clarasr-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file clarasr-0.1.2.tar.gz.

File metadata

  • Download URL: clarasr-0.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for clarasr-0.1.2.tar.gz
Algorithm Hash digest
SHA256 df3826c510d7cd2b466536faadfdcfb783a0d63653a1221855ed67b999f8efa5
MD5 a626c79f403d2ea5548563a7611a2ec1
BLAKE2b-256 39a1c194cb97ebcbabc6b2ee2c79d37fe8313d607ba5520e0df3e7e965f14073

See more details on using hashes here.

File details

Details for the file clarasr-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: clarasr-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for clarasr-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 435a8095dbcfa6a1ba7e73fdd08d7ac52395f5cb29685bc4bda7d716ec455629
MD5 c1ae47d7664902dcafc0bd15019d428c
BLAKE2b-256 eebfbe5238142b91e9ca4bee3f52d61ff81a7a4d4e78980224d3fefca0bb7f00

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